[New-bugs-announce] [issue20502] Context.create_decimal_from_float() inconsistent precision for zeros after decimal mark

Mauricio de Alencar report at bugs.python.org
Mon Feb 3 15:28:52 CET 2014


New submission from Mauricio de Alencar:

The following code demonstrates an inconsistency of this method in dealing with zeros after the decimal mark.


from decimal import Context

context = Context(prec=2)

for x in [100., 10., 1., 0.1]:
    print(context.create_decimal_from_float(x), context.create_decimal_from_float(4.56*x))


Produces the output:
1.0E+2 4.6E+2
10 46
1 4.6
0.10 0.46

Line 3 is inconsistent. It should be "1.0 4.6".

----------
messages: 210131
nosy: mdealencar
priority: normal
severity: normal
status: open
title: Context.create_decimal_from_float() inconsistent precision for zeros after decimal mark
type: behavior
versions: Python 3.3

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


More information about the New-bugs-announce mailing list