[Python-Dev] Re: PEP239 (Rational Numbers) Reference
Implementation and new issues
Tim Peters
tim.one@comcast.net
Thu, 03 Oct 2002 02:01:49 -0400
[Oren Tirosh]
> But why would you want to convert floating point numbers to rationals
> in the first place?
For one thing, to continue an exact calculation that has grown too large to
continue in floating-point without losing information, but where the extreme
expense of using rationals instead of floating point pushes you toward using
fp just as long as you can.
> Floating point numbers are generally inexact.
The IEEE-754 standard mandates an "inexact flag" (and your HW has one) for
this very kind of purpose. Your FPU knows for certain whether you've ever
lost a bit of information when doing basic fp operations; unfortunately,
it's still extremely clumsy to get at this info.
> Converting them to exact rationals can give a false sense of
> exactitude.
So can printing more digits than warranted <wink>.
> Any calculation involving a floating point number should taint
> the result with inexactitude and yield a floating point result.
How old are you? See -- integers can be inexact too. Representation has
nothing to do with exactness, which is one part of this story Scheme got
straight.