[issue12245] Document the meaning of FLT_ROUNDS constants for sys.float_info

Mark Dickinson report at bugs.python.org
Sat Jun 4 17:14:43 CEST 2011


Mark Dickinson <dickinsm at gmail.com> added the comment:

float_info.rounds is a bit of an odd fish, and I think it was probably a mistake to include it in sys.float_info in the first place.

All the other float_info fields relate to parameters of the floating-point format, which is fixed, useful information.  In contrast, float_info.rounds gives information about the current FPU settings, which are variable.  Moreover, it doesn't do that very well:  all it does is give information about the FPU settings at the time that Python was compiled, which isn't really very helpful (and perhaps not even that:  it reports the value of FLT_ROUNDS, which may not even reflect those FPU settings accurately).  I wouldn't mind seeing this field fade quietly into obscurity.

FWIW, the value is taken from C's FLT_ROUNDS, and its interpretation is *supposed* to be the following (C99 5.2.4.2.2, para 7):

  -1:  The compiler was unable to determine rounding mode.
   0:  Round towards zero.
   1:  Round to nearest (this is the most likely value for
       float_info.rounds on common platforms).
   2:  Round towards positive infinity
   3:  Round towards negative infinity.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12245>
_______________________________________


More information about the Python-bugs-list mailing list