[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: arithmetics bug?
- From: vitaminx <vitaminx@...>
- Date: Sun, 31 Mar 2013 16:06:27 +0800
Hi,
I'm using lua 5.2.1-3 amd64 on Debian Linux unstable.
With this simple one-liner I can reproduce the following arithmetic error:
for var=10,0,-0.1 do print(var) end
The output on the console is:
$ lua test.lua
10
9.9
9.8
9.7
9.6
9.5
9.4
-- cutted, everyting normal until here
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1
0.90000000000002
0.80000000000002
0.70000000000002
0.60000000000002
0.50000000000002
0.40000000000002
0.30000000000002
0.20000000000002
0.10000000000002
1.8790524691781e-14
Where comes the additional 0.00000000000002 from?
I've tried with a for loop with ranges smaller than 10 to 0 and there
are also errors, mostly the integer which should be zero is wrong.
Regards,
vitaminx