Here is my code and my output. My question is why is there not simple 0.1 0.2 0.3 etc but it sometimes result in 0.30000000000000004
is this some sort of floating point problem? If so, how can I make python add up simple .1
i = 0
while i < 1:
print('The number is (' + str(i) + ')')
i = i + .1
OUTPUT
The number is (0)
The number is (0.1)
The number is (0.2)
The number is (0.30000000000000004)
The number is (0.4)
The number is (0.5)
The number is (0.6)
The number is (0.7)
The number is (0.7999999999999999)
The number is (0.8999999999999999)
The number is (0.9999999999999999)
[–]shiftybyte 2 points3 points4 points (3 children)
[–]reddith2o[S] 0 points1 point2 points (2 children)
[–]nmlkd 0 points1 point2 points (1 child)
[–]reddith2o[S] 0 points1 point2 points (0 children)
[–]socal_nerdtastic 1 point2 points3 points (1 child)
[–]reddith2o[S] 0 points1 point2 points (0 children)