浮点加法中的错误:是否有其他人看到这个? [英] Bug in floating-point addition: is anyone else seeing this?
问题描述
在SuSE 10.2 / Xeon上,似乎有一个四舍五入的错误,即
浮点数增加:
dickinsm @ weyl:~python
Python 2.5(r25:51908,2007年5月25日,16:14:04)
[gCC 4.1.2 20061115(预发布)(SUSE Linux)] on linux2
输入help,copyright,credit等等。或许可证或欲获得更多信息。
>> a = 1e16-2。
a
9999999999999998.0
>>> a + 0.999#给出预期结果
9999999999999998.0
>> a + 0.9999#没有正确回合。
10000000000000000.0
这里的最后一个结果应该是9999999999999998.0,
不是10000000000000000.0。有没有人看到这个
的错误,还是只是我系统的怪癖?
Mark
Mark Dickinson schrieb:
在SuSE 10.2 / Xeon上似乎有一个四舍五入的错误
浮点加法:
dickinsm @ weyl:~python
Python 2.5(r25:51908,2007年5月25日,16:14:04)
[gCC 4.1.2 20061115(预发布)(SUSE Linux)] on linux2
输入help,copyright,credit等等。或许可证或欲获得更多信息。
>>> a = 1e16-2。
a
9999999999999998.0
>>> a + 0.999#给出预期结果
9999999999999998.0
>>> a + 0.9999#不正确圆。
10000000000000000.0
这里的最后一个结果应该是9999999999999998.0,
not not 10000000000000000.0。是否有其他人看到这个
错误,还是只是我系统的怪癖?
它在OSX下工作:
(TG1044)mac-dir:〜/ projects / artnology / Van_Abbe_RMS / Van -Abbe-RMS deets
python
Python 2.5.1(r251:54869,2007年4月18日,22:08:04)
[GCC 4.0.1(Apple Computer,Inc。build 5367)]在darwin上
输入help,copyright,credit等等。或许可证或欲了解更多信息。
欢迎来到rlcompleter2 0.96
获得不错的体验< tabmultiple times
>> a = 1e16-2。
a
9999999999999998.0
>> a + 0.9999
9999999999999998.0
>>>
但在linux下,我得到了同样的行为:
Python 2.5.1 (r251:54863,2007年5月2日,16:56:35)
[GCC 4.1.2(Ubuntu 4.1.2-0ubuntu4)] on linux2
类型"帮助,版权,信用或许可证或欲了解更多信息。
欢迎来到rlcompleter2 0.96
获得不错的体验< tabmultiple times
>> a = 1e16-2。
a + 0.9999
10000000000000000.0
>>>
所以 - 在我看来它是一个Linux的东西。我不太了解
IEEE-floats对原因做出任何假设。
Diez
5月21日上午11:38,Mark Dickinson< dicki ... @ gmail.comwrote:
On SuSE 10.2 / Xeon对于
浮点数似乎有一个舍入错误:
dickinsm @ weyl:~python
Python 2.5( r25:51908,2007年5月25日,16:14:04)
[gCC 4.1.2 20061115(预发布)(SUSE Linux)] on linux2
输入help ;,版权,信用;或许可证或有关更多信息,请参阅>> a = 1e16-2。
> a
9999999999999998.0
> a + 0.999#给出预期结果
9999999999999998.0
> a + 0.9999#没有正确舍入。
10000000000000000.0
这里的最后一个结果应该是9999999999999998.0,
not not 10000000000000000.0。有没有人看到这个
的错误,还是只是我系统的怪癖?
Mark
我也看到了
On SuSE 10.2/Xeon there seems to be a rounding bug for
floating-point addition:
dickinsm@weyl:~python
Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>a = 1e16-2.
a
9999999999999998.0
>>a+0.999 # gives expected result
9999999999999998.0
>>a+0.9999 # doesn''t round correctly.
10000000000000000.0
The last result here should be 9999999999999998.0,
not 10000000000000000.0. Is anyone else seeing this
bug, or is it just a quirk of my system?
Mark
Mark Dickinson schrieb:On SuSE 10.2/Xeon there seems to be a rounding bug for
floating-point addition:
dickinsm@weyl:~python
Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>>a = 1e16-2.
a
9999999999999998.0
>>>a+0.999 # gives expected result
9999999999999998.0
>>>a+0.9999 # doesn''t round correctly.
10000000000000000.0
The last result here should be 9999999999999998.0,
not 10000000000000000.0. Is anyone else seeing this
bug, or is it just a quirk of my system?It is working under OSX:
(TG1044)mac-dir:~/projects/artnology/Van_Abbe_RMS/Van-Abbe-RMS deets
python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times>>a = 1e16-2.
a
9999999999999998.0
>>a+0.9999
9999999999999998.0
>>>
But under linux, I get the same behavior:
Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times>>a = 1e16-2.
a+0.9999
10000000000000000.0
>>>
So - seems to me it''s a linux-thing. I don''t know enough about
IEEE-floats to make any assumptions on the reasons for that.
Diez
On May 21, 11:38 am, Mark Dickinson <dicki...@gmail.comwrote:On SuSE 10.2/Xeon there seems to be a rounding bug for
floating-point addition:
dickinsm@weyl:~python
Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>a = 1e16-2.>a
9999999999999998.0
>a+0.999 # gives expected result
9999999999999998.0
>a+0.9999 # doesn''t round correctly.
10000000000000000.0
The last result here should be 9999999999999998.0,
not 10000000000000000.0. Is anyone else seeing this
bug, or is it just a quirk of my system?
MarkI see it too
这篇关于浮点加法中的错误:是否有其他人看到这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!