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/098918.html below:

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

[Python-Dev] Mixing float and Decimal -- thread rebootAdam Olsen rhamph at gmail.com
Fri Mar 26 00:10:56 CET 2010
On Thu, Mar 25, 2010 at 04:18, Steven D'Aprano <steve at pearwood.info> wrote:
> def myfunc(x, y):
>    if x == y:
>        return 1.0
>    else:
>        return something_complicated**(x-y)
>
>
> Optimising floating point code is fraught with dangers (the above fails
> for x=y=INF as well as NAN) but anything that make Not A Numbers
> pretend to be numbers is a bad thing.

What about this:

def myfunc(x):
    if x >= THRESHOLD:
        return 1.0
    else:
        return something_complicated(x)

If one behaves right it's more likely a fluke, not a designed in
feature.  It's certainly not obvious without covering every comparison
with comments.

Maybe that's the solution.  Signal by default on comparison, but add a
collection of naneq/naneg/etc functions (math module, methods,
whatever) that use a particular quiet mapping, making the whole thing
explicit?


-- 
Adam Olsen, aka Rhamphoryncus
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