Storing floats, etc in GOODS

Jarvis, Robert P. (Bob) (Contingent) bob.jarvis at timken.com
Fri Oct 22 17:41:44 UTC 2004


3.2 is one of the many numbers which cannot be exactly represented using
IEEE floating-point values.  Changing to use IEEE 64-bit format won't fix
the problem either because 3.2, when stored as an IEEE 64-bit floating point
value, is stored as 3.2000000000000002.  This is an example of why putting
monetary values in floating point variables is not a good idea.  Perhaps you
could use Fraction or ScaledDecimal if they are appropriate?

Very respectfully,
Bob Jarvis

> -----Original Message-----
> From: Yar Hwee Boon [mailto:hboon at motionobj.com]
> Sent: Friday, October 22, 2004 9:09 AM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Storing floats, etc in GOODS
> 
> 
> 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.
> 
> -- 
> Regards
> HweeBoon
> MotionObj
> 

-----------------------------------------
**********************************************************************
PLEASE NOTE: The above email address has recently changed from a previous
naming standard -- if this does not match your records, please update them
to use this new name in future email addressed to this individual.    This
message and any attachments are intended for the   individual or entity
named above. If you are not the intended  recipient, please do not forward,
copy, print, use or disclose this   communication to others; also please
notify the sender by   replying to this message, and then delete it from
your system.     The Timken Company
**********************************************************************




More information about the Squeak-dev mailing list