On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote:

> Sorry to come in so late in this discussion. Although it is correct to
> say that many real numbers that have an exact decimal representation
> cannot be exactly represented in binary, that is no excuse to print 53.6
> as 53.600000000000001. This is just lousy printing and the fact that
> this kind of question comes up every week shows that it is confusing to
> many people.

Good. That's a feature, not a bug.

Floats *are* confusing and unintuitive. Anyone with pretensions to be a 
programmer should get over the illusion that floats are reals as soon as 
possible, before they learn bad habits that have to be unlearned. If that 
starts with them asking why they get 53.600000000000001 instead of 53.6, 
so be it. If they want to be insulated from the harsh reality, they can 
do this:

>>> print 53.6
53.6



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to