How I can add EUR_GET1 + EUR_GET2 + EUR_GET3 and put the result in fAdd and with the same format ** in RESULT (eeprom_int)?
Thanks
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
Posted: Tue Feb 07, 2006 4:32 pm
First a remark: are you sure you want to use float variables? Floating point arithmetic has the disadvantage of requiring a lot of program memory space and you will create strange rounding errors like '1 + 1 = 1.99999999'.
There is another technique that doesn't have these problems, it is called 'scaled integers'. With this technique you are always calculating in integers which is much easier to the processor. For your problem this means you are not going to calculate in Euro's but in Euro cents, only at the times you are showing the result to the user you are adding the decimal point to the output.
Another suggestion to make life easier on yourself is by not storing the values in EEPROM as a text string but as integer values. Only do the conversion to text strings when showing the results to the user.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum