[Python-Dev] decimal.py signals & traps

Tim Peters tim.peters at gmail.com
Tue Jul 13 05:41:02 CEST 2004


[Michael Hudson] 
>> Well, there's an argument that this may not be the most natural
>> interface for a C implementation or for an implementation of such
>> things for floats -- but this is an argument involving predicting the
>> future, so probably should be ignored.

[Greg Ewing]
> I don't think it should be ignored. If the future is uncertain, surely
> it would be better to err on the side of *not* exposing implementation
> details?

Since virtually all modern processors implement sticky flags, trap
enablers, and rounding modes in FPU context & control registers,
virtually all modern compilers support some idiosyncratic way to set
and query them.  Google on ieee_flags for one extreme in C, entirely
string-based.  Google on _control87 and/or _controlfp for the other C
extreme, passing ints, with a pile of #defines to give different bits
different meanings.

Both of those actually hide the implementation quite well -- although
the latter is most often implemented in such a way that the bit
positions remarkably <ahem> correspond exactly to their meanings in
the Pentium instructions that fiddle FPU context.


More information about the Python-Dev mailing list