[issue5448] Add precision property to decimal.Decimal

Raymond Hettinger report at bugs.python.org
Mon Mar 9 12:30:10 CET 2009


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

FWIW, there is a public API to get at the same information: 
Decimal.as_tuple().

That being said, I don't see how your len(value._int) test could be
correct.  The exponent will potentially shift the value way
out-of-bounds for a database.  Consider Decimal('999E+10') or
Decimal('999E-10') whose database storage sizes do not fit in a
DECIMAL(7,4) field eventhough their len(value._int) is three.


To see if the fractional part of a decimal number fits in a database,
set the context precision to the database precision and quantize the
decimal to the allowed number of decimal places.  If the Inexact flag
gets set, then it didn't fit.

-1 on extending the API any further from the underlying IBM specification.

----------
message_count: 1.0 -> 2.0
nosy: +rhettinger
nosy_count: 1.0 -> 2.0
resolution:  -> rejected
status: open -> closed

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


More information about the Python-bugs-list mailing list