[Python-ideas] Python Numbers as Human Concept Decimal System

Stefan Krah stefan at bytereef.org
Sun Mar 9 22:57:15 CET 2014


Guido van Rossum <guido at python.org> wrote:
> I would dearly like to put this thread to rest, as it has strayed mightily from
> the topic of improvements to Python, and all points of view have been amply
> defended. I'm hoping to hear from Cowlishaw, but I expect he'll side with one
> of Mark Dickinson's proposals. I hope that somebody will take up the task to
> write a PEP about introducing a decimal literal; that sounds like an obtainable
> goal, less controversial than changing Decimal(<float>).

One more thing that hasn't been mentioned yet: Java's BigDecimal constructor
appears to perform exact double -> Decimal conversions, unless a context
is passed:

http://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html


"""
BigDecimal(double val)
Translates a double into a BigDecimal which is the exact decimal representation of the double's binary floating-point value.
BigDecimal(double val, MathContext mc)
Translates a double into a BigDecimal, with rounding according to the context settings.
"""


I strongly suspect that this matches Mike Cowlishaw's preference.



Stefan Krah





More information about the Python-ideas mailing list