I want to count from 0.0001 to 1 with 0.0001 steps in ruby. I wrote this code but it enters to an infinite loop. Somewhy the interpreter does a wrong summation.
x = 0.0001
while x != 1.0
puts x
x = x + 0.0001
end
Here is the first 10 value it gives:
0.0001
0.0002
0.00030000000000000003
0.0004
0.0005
0.0006000000000000001
0.0007000000000000001
0.0008000000000000001
0.0009000000000000002
0.0010000000000000002
It should be 0.0001, 0.0002, 0.0003, etc... How can I make it working? Thanks!