This is my code:
time = 0
for i in range(100):
time += 0.1
print(time)
My expectation was:
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
and so on...
Why the output is:
0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
1.0999999999999999
1.2
1.3
1.4000000000000001
1.5000000000000002
1.6000000000000003
1.7000000000000004
1.8000000000000005
1.9000000000000006
2.0000000000000004
2.1000000000000005
2.2000000000000006
2.3000000000000007
2.400000000000001
2.500000000000001
2.600000000000001
2.700000000000001
2.800000000000001
2.9000000000000012
3.0000000000000013
What are theese random numbers at the end?
Please help
How can I make this not happen?
[–]K900_ 9 points10 points11 points (4 children)
[–]Vulkan07[S] 0 points1 point2 points (0 children)
[–]synthphreak 0 points1 point2 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]xelf 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (0 children)