Mark Dickinson <[email protected]> added the comment:
One also has to worry about the exponent of the converted result: e.g.,
should Decimal.from_float(10.0) produce Decimal('1E1') or Decimal('10')?
The latter looks nicer, to me.
IEEE 754 isn't much help here: as far as I can tell it says nothing about
binary <-> decimal conversions.
I see two reasonable strategies: (1) always use the largest exponent
possible (so we'd get Decimal('1E1') above), or (2) when the quantity
converted is an exact integer, use an exponent of zero; otherwise fall
back to (1).
Option (2) is pretty much what the recipe in the docs does already, I
think: it computes a quotient of two Decimals, each having exponent zero,
so the preferred exponent of the result is also zero.
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue4796>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com