+ 2
Funny while loop output in playground
Why do i get more than one decimal in Ruby Code Playground? I have this while loop: x = 0 while x < 4 puts x x += 0.2 end and the output in playground: 0 0.2 0.4 0.6000000000000001 0.8 1.0 1.2 1.4 1.5999999999999999 1.7999999999999998 1.9999999999999998 2.1999999999999997 2.4 2.6 2.8000000000000003 3.0000000000000004 3.2000000000000006 3.400000000000001 3.600000000000001 3.800000000000001
2 Respuestas
+ 10
Hahaha, I guess it's the playground error! Actually, it is not following the rules exactly as we specified!!!
+ 6
Code Playground ftw xD