[Tutor] extreme basics

Mr Gerard Kelly s4027340 at student.uq.edu.au
Mon Jan 5 08:59:06 CET 2009


This is extremely weird, I think.

Here is a tiny program:

from math import *
from Numeric import *

x=[0]*10


for counter in rangelen((x)):
      x[counter]=counter*0.1

print x

Here is what I get:

[0.0, 0.10000000000000001, 0.20000000000000001, 0.30000000000000004,
0.40000000000000002, 0.5, 0.60000000000000009, 0.70000000000000007,
0.80000000000000004, 0.90000000000000002]

What on Earth is going on with those decimals at the end? Is this a
floating point thing?


More information about the Tutor mailing list