[Tutor] list of floats, strange behavior

Bernard Lebel python at bernardlebel.com
Wed Sep 1 10:18:34 CEST 2004


Hi,

In the tutorial (I think) from the Python docs there is an explanation about
this problem, wich is inherent to floating point numbers in computers.
Very interesting read.


Cheers
Bernard

----- Original Message ----- 
From: <tpc at csua.berkeley.edu>
To: <tutor at python.org>
Sent: Wednesday, September 01, 2004 8:35 AM
Subject: [Tutor] list of floats, strange behavior


>
> hi everybody, I was wondering if someone could help me understand why IDLE
> seems to expand the largest value in a series of floating points I decided
> to put in a list:
>
> >>> list01 = [.1028, .1248, .0998, .1101, .1062]
> >>> list01.sort()
> >>> list01
> [0.0998, 0.1028, 0.1062, 0.1101, 0.12479999999999999]
>
> I don't particularly want that value expanded like that.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>




More information about the Tutor mailing list