I wrote a test routine that multiplies and casts every number from 0.0001 to 0.9999 and outputs to a text file via a conduit for analysis. I haven't sifted through the whole set yet but so far I found these to be "trouble numbers": 0.141 - 0.143 0.172 - 0.174 0.204 0.284 - 0.286 0.344 - 0.349 0.407 - 0.409 0.563 - 0.573
I was thinking I might find a pattern and maybe special case these numbers but I'm not smart enough to see a pattern here. I think I'll try Jerome's suggestion instead. "Jim McGowen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Found something strange... Looks like Palm OS 5 changes certain numbers > multiplying. For example: > double x = 0.141; > long y = (long)( x * 10000.0 ); > > y becomes 1409. > > Also: > double x = 1410.0; > double test = 0.141; > double y = test * 10000.0; > double z = 0.141 * 10000.0; > > x = = 1410.0 = = > 0100000010010110000010000000000000000000000000000000000000000000 > y = = 1410.0 = = > 0100000010010110000001111111111111111111111111111111111111111111 > z = =1410.0 = = > 0100000010010110000010000000000000000000000000000000000000000000 > > Casting z to a long gives 1409. > Only happens with certain "problem" numbers like this one. Haven't tried > it in any other OS version. Is there a way to fix or get around this? > > - Jim > > -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
