Bug in floating-point addition: is anyone else seeing this?
Dave Parker
daveparker at flamingthunder.com
Wed May 21 16:34:14 EDT 2008
On May 21, 12:38 pm, Mark Dickinson <dicki... at gmail.com> wrote:
> >>> a+0.999 # gives expected result
> 9999999999999998.0
> >>> a+0.9999 # doesn't round correctly.
>
> 10000000000000000.0
Shouldn't both of them give 9999999999999999.0?
I wrote the same program under Flaming Thunder:
Set a to 10^16-2.0.
Writeline a+0.999.
Writeline a+0.9999.
and got:
9999999999999998.999
9999999999999998.9999
I then set the precision down to 16 decimal digits to emulate Python:
Set realdecimaldigits to 16.
Set a to 10^16-2.0.
Writeline a+0.999.
Writeline a+0.9999.
and got:
9999999999999999.0
9999999999999999.0
More information about the Python-list
mailing list