[New-bugs-announce] [issue2937] Incorrect rounding in floating-point operations with gcc/x87

Mark Dickinson report at bugs.python.org
Wed May 21 22:36:57 CEST 2008

New submission from Mark Dickinson <dickinsm at gmail.com>:

On some older Intel 32-bit hardware, under Linux, floating-point 
operations don't always give correctly rounded results.  Here's an 
example involving addition, on SuSE Linux 10.2/Xeon.

Python 2.6a3+ (trunk:63521, May 21 2008, 15:40:39) 
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1e16 + 2.999
>>> 1e16 + 2.9999

The second result should really be 1e16+2., not 1e16+4.  This appears to 
be related to this GCC issue:


Various fixes are possible.  One possible fix is to add the -ffloat-
store flag to the gcc options.  Another is to use the information in 
fpu_control.h, if available, to set the precision control.  Yet another 
is to sprinkle some 'volatile' modifiers throughout floatobject.c.

It's not clear to me that this *should* be fixed, but I think the 
problem should at least be documented.  Hence this bug report.

components: Interpreter Core
messages: 67174
nosy: marketdickinson
priority: normal
severity: normal
status: open
title: Incorrect rounding in floating-point operations with gcc/x87
type: behavior
versions: Python 2.6, Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list