[issue8786] Add support for IEEE 754 contexts to decimal module.

Stefan Krah report at bugs.python.org
Fri Aug 30 18:08:54 CEST 2013


Stefan Krah added the comment:

BTW, in _decimal the feature can already be enabled with:

./configure CFLAGS=-DEXTRA_FUNCTIONALITY


>>> IEEEContext(DECIMAL128)
Context(prec=34, rounding=ROUND_HALF_EVEN, Emin=-6143, Emax=6144, capitals=1, clamp=1, flags=[], traps=[])
>>> IEEEContext(DECIMAL64)
Context(prec=16, rounding=ROUND_HALF_EVEN, Emin=-383, Emax=384, capitals=1, clamp=1, flags=[], traps=[])
>>> IEEEContext(DECIMAL32)
Context(prec=7, rounding=ROUND_HALF_EVEN, Emin=-95, Emax=96, capitals=1, clamp=1, flags=[], traps=[])
>>>


>>> IEEEContext(512)
Context(prec=142, rounding=ROUND_HALF_EVEN, Emin=-103079215103, Emax=103079215104, capitals=1, clamp=1, flags=[], traps=[])
>>> IEEEContext(1024)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: argument must be a multiple of 32, with a maximum of 512
>>>

Of course this isn't the official API yet, but I think it's
reasonable.

----------

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


More information about the Python-bugs-list mailing list