On Fri, 2003-01-24 at 08:33, Enrico Pavesi wrote:
> There is a problem in float operation on Codewarrior 8.3 Palm.
>
> RigaOrdine.importo =(dTemp * RigaOrdine.qta)
>
> Where
> double dTemp = 12.91100000000000
> double RigaOrdine.qta=5.000000000000000
>
> Gives 64.55499999999999
> INSTEAD OF 64.55500000000000
>
> Is this a known problem?
>
It's only a "problem" in the way that computers represent floating point
numbers internally. I used to have a pointer to a paper that described
what goes on under the covers, but I can't lay my hands on it at the
moment. A google search should be able to turn up something.
Basically though, it boils down to the fact that you can't represent
every possible floating point number exactly as a binary value (at least
not using the common scheme of storing floating points). Instead you
end up with round-off errors like you see in the example you gave. For
all practical purposes, 64.554999999.... == 64.55500000000.
> Is there any workaround?
Lower your expectations as to the precision of computers? :-)
There are ways to store floats more precisely, but the trade-off usually
comes in terms of the amount of storage space and/or processing power.
/dwight
--
Dwight N. Tovey
Email: [EMAIL PROTECTED]
http://www.dtovey.net/dwight
---
Nothing is foolproof to a talented fool.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/