[Python-Dev] Revamping Python's Numeric Model
Moshe Zadka
Moshe Zadka <moshez@math.huji.ac.il>
Mon, 6 Nov 2000 12:42:34 +0200 (IST)
[Tim Peters]
> Some quickies for now:
>
> + Konrad Hinsen needs to be sucked in. He's been arguing for a "unified"
> numeric model forever.
OK, I hope this e-mail address reaches him: I got it off his webpage.
[Tim Peters]
> + Everyone has IEEE-754 fp hardware today; some people actually want to use
> it; Moshe doesn't, but whatever revamping we get needs to allow others their
> delusions too.
My proposal has nothing *against* 754 either. For example, "all inexact
operations are done compliant to 754" is a perfectly acceptable addition.
[Tim Peters, about rationals]
> (provided they're *displayed* in rounded decimal fp notation (restart
> "str" vs "repr" rant, and that the interactive prompt uses the wrong one,
> and ditto str(container))),
Tim, that's the other PEP <wink>
[Tim Peters]
> IEEE-754 defines exactly what to do with this, for binary floats (and your
> hardware has an "inexact result" flag set or not after every fp operation).
Cool! I didn't know about that.
[Tim Peters]
> Conversion of the string "1.0" to float must not set it; conversion of "0.1"
> must set it; and similarly for + - * / sqrt: "inexact result" gets set
> whenever the infinitely precise result differs from the computed result.
Is there some API for it in C? If not, we might as well assume that any
floating point number is inexact.
[Tim Peters]
> So
> inexactness there is neither a property of types nor of numbers, but of
> specific computations. Extreme example:
>
> x = 1./3. # inexact
> y = x-x # exact result (from inexact inputs!)
>
> I know that this version (operation-based) of inexactness can be useful. I
> see almost no earthly use for calling every number of a given type inexact.
> Tagging individual numbers with an exact/inexact bit is an extremely crude
> form of interval arithmetic (where the intervals are single points or
> infinite).
The tagging is whether you *want* exact operations or inexact operations.
I.e.:
1.0/3 --> inexact
1/3 --> exact.
Well, this is the classical definition of "type": what do the operations
mean? Which is why I need the inexact() function in my PEP.
--
Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez