HELP: restore my faith in Python

Mirko Liss n89553 at stud.upb.de
Thu Mar 9 12:10:19 EST 2000


Ken Seehof wrote:
> 
> Seems to me an improvement would be to have python artificially
> add epsilon to floats before converting to int.  This would still
> suck but IMHO it would suck less.

It's not just the conversion to int. As soon as you tell the 
programmer not to expect the worst from floats, he'll invent
other ways to make a mess with those ugly floating point numbers.

Want an example?

>>> pennies1, pennies2 = 3.0 / 20 , 3 * 0.05
>>> menu = { pennies1 : "spam" } 
>>> menu[pennies2] =  "lobster" 
>>> menu
{0.15: 'lobster', 0.15: 'spam'}

Ooops !
So the division 3.0/20 is just a bit inaccurate, isn't it?
But who cares, as long as I get at the sea food.
So I count my pennies and ...

>>> menu[0.15]
'spam'



Spicy regards,

Mirko

-- 
M Liß, n89553 at squid.upb.de



More information about the Python-list mailing list