[Python-Dev] Minutes from the Numeric Coercion dev-day session

Thomas Wouters thomas@xs4all.net
Tue, 13 Mar 2001 12:54:19 +0100


On Tue, Mar 13, 2001 at 05:18:35AM -0500, Guido van Rossum wrote:

> I think the extent to which HWFP doesn't work for newbies is mostly
> related to the change we made in 2.0 where repr() (and hence the
> interactive prompt) show full precision, leading to annoyances like
> repr(1.1) == '1.1000000000000001'.
> 
> I've noticed that the number of complaints I see about this went way up
> after 2.0 was released.
> 
> I expect that most newbies don't use floating point in a fancy way, and
> would never notice it if it was slightly off as long as the output was
> rounded like it was before 2.0.

I suspect that the change in float.__repr__() did reduce the number of
suprises over something like this, though: (taken from a 1.5.2 interpreter)

>>> x = 1.000000000001
>>> x
1.0
>>> x == 1.0
0

If we go for the HWFP + loosened precision in printing you seem to prefer,
we should be concious about this, possibly raising a warning when comparing
floats in this way. (Or in any way at all ? Given that when you compare two
floats, you either didn't intend to, or your name is Tim or Moshe and you
would be just as happy writing the IEEE754 binary representation directly :)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!