Storing floats, etc in GOODS
C. David Shaffer
cdshaffer at acm.org
Fri Oct 22 13:38:30 UTC 2004
Yar Hwee Boon wrote:
> Hi
>
> Storing floats, etc in GOODS, using Avi Bryant's client, numbers such
> as 3.2 are returned as 3.199999809265137. Seems that GOODS stores
> floats using the IEEE 32 bit format. How do you work around it? I'm
> storing money one in currency only. Create a currency class, maybe?
> Thanks.
>
I can't speak for the GOODS-related issues but I highly recommend if
you're going to deal with Currency you develop a class (or classes) to
support exact representations. At the lowest level I store all
currencies as integer-like things...this is the only solution that has
stood the test of time for me.
David
More information about the Squeak-dev
mailing list
|