PDA

View Full Version : variable + decimal



savnik
- 18th August 2009, 13:24
I have a variable as word
XL VAR WORD
LO VAR XL.LOWBYTE
HI VAR XL.HIGHBYTE
and a decimal number.
How can to add the decimal to variable and after to write to eeprom;
like this : 13000(variable) + 622,784(decimal - is always the same number) = 13622,784
The decimal 622,784 is from division 38,924/0,0625

Jerson
- 18th August 2009, 13:44
Doing 13000 + 623.4
is same as doing
13000*10 + 623.4*10
=136234

when you want to recover it, simply divide by 10 to get the result
=13623.4

You have to make sure to live within the integer limits of PBP unless you are using the long version PBPL.

savnik
- 18th August 2009, 13:49
I can live with the integer limits of PBP.
I can not use PBPL because i use pic16f88.

Acetronics2
- 18th August 2009, 13:57
Hi, Savnik

Is your decimal number a constant ??? ... and could you tell us where it comes from.

as



The decimal 622,784 is from division 38,924/0,0625


and ALSO the same as ...

38,924 * 16 !!!

Alain

savnik
- 18th August 2009, 14:21
Yes it is a constant number.
is from : 28,224+10,7 = 38,924 and the 0,0625 is the step