I'm not exactly stuck. Unexpected results?


#1



this exercise:


I'm trying to modify the increments to zero point something. when it runs, the increment has deviation to my code? is this expected on any ruby distribution, or only this one?
for example:

i = 0
while i < 5
  puts i
  # Add your code here!
  i = i + 0.001
end


#2

This video should help you understand why you aren't getting the values that you are expecting.

My computer was pretty unhappy with running the number of iterations your code asks for. You can see the same problem quicker with this:

i = 0
while i < 2
  puts i
  i = i + 0.1
end

You can run it here https://repl.it/languages/ruby if you'd like.


#3

I see. Thanks.

Where can I learn more about this topic?


#4

To find out more about this, I would do a web search for

floating point numbers ruby