From: Leon N. M. <leo...@gm...> - 2010-09-01 00:41:31
|
This should now be fixed: > 1 s>f _pi f* 1000000. d>f f* f>d d. 3141592 ok > -1 s>f _pi f* 1000000. d>f f* f>d d. -3141593 ok the discrepency in the smallest digit is due to the way the fractional part gets truncated (it rounds down). If you look directly at the float (take out the f>d and convert to binary) they are now idenetical except for the sign bit: 01001010001111111011111101100010 11001010001111111011111101100010 It turns out the root cause was something like this: > -13176795. d2/ d. -6588398 ok > 13176795. d2/ d. 6588397 ok Which is how it should work if you think of division by 2 as shifting right, but isn't something I had taken in to account -- a good lesson in how negative numbers are represented. My reposititory has been updated -- keep the tests coming. -Leon On Monday, August 30, 2010 04:46:37 pm you wrote: > Leon, > > I think there is an issue with negative numbers: > > -1 s>f fconstant _-1 >>>> define 1.0 > > ok > > > 1 s>f fconstant _1 >>>> define -1.0 > > ok > > > _1 _pi f* _1e4 f* f>s . >>>> 1.0 * pi * 1.0E4 = 31415 > > 31415 ok > > > _-1 _pi f* _1e4 f* f>s . >>>>> -1.0 * pi * 1.0E4 = -31426 > > -31426 ok > > > It cannot be caused by of a rounding error accumulating or loosing a > valid digits. Some minor bug somewhere.. > P. |