[Python-Dev] Round Bug in Python 1.6?

Tim Peters tim_one@email.msn.com
Sun, 9 Apr 2000 16:14:25 -0400


[Ping]
> ...
> I think "fewest digits needed to distinguish the correct value"
> will give good and least-surprising results here.  This method
> guarantees:
>
>     - If you just type a number in and the interpreter
>       prints it back, it will never respond with more
>       junk digits than you typed.

Note the example from another reply of a machine with 2-bit floats.  There
the user would see:

>>> 0.75   # happens to be exactly representable on this machine
0.8        # because that's the shortest string needed on this machine
           # to get back 0.75 internally
>>

This kind of surprise is inherent in the approach, not specific to 2-bit
machines <wink>.

BTW, I don't know that it will never print more digits than you type:  did
you prove that?  It's plausible, but many plausible claims about fp turn out
to be false.

>     - If you type in what the interpreter displays for a
>       float, you can be assured of getting the same value.

This isn't of value for most interactive use -- in general you want to see
the range of a number, not enough to get 53 bits exactly (that's beyond the
limits of human "number sense").  It also has one clearly bad aspect:  when
printing containers full of floats, the number of digits printed for each
will vary wildly from float to float.  Makes for an unfriendly display.  If
the prompt's display function were settable, I'd probably plug in pprint!