A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-March/098699.html below:

[Python-Dev] Mixing float and Decimal -- thread reboot

[Python-Dev] Mixing float and Decimal -- thread reboot [Python-Dev] Mixing float and Decimal -- thread rebootRaymond Hettinger raymond.hettinger at gmail.com
Mon Mar 22 20:36:18 CET 2010
One other thought.

The Decimal constructor should now accept floats as a possible input type.
Formerly, we separated that out to Decimal.from_float() because
decimals weren't interoperable with floats.

This will put decimal and float back on equal footing so that we have both:
    float(some_decimal)        # coerce to binary float
and
    Decimal(some_float)       # coerce to decimal float

That will also save us from odd idioms like:

    d = some_float + Decimal(0)   # coerce to decimal then apply context rounding

This also matches the behavior of other constructors:
    int(some_float)
or
    int(some_decimal)
or
    str(some_float)
or
    str(some_decimal)


Raymond

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4