Created
October 29, 2013 21:10
-
-
Save apiguy/7222667 to your computer and use it in GitHub Desktop.
Demonstrates how floats can be inaccurate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time = .0 | |
seconds = 0 | |
while True: | |
time += .1 | |
seconds = int(time) | |
print "---------------" | |
print "Time to str: ", time | |
print "Time to int: ", int(time) | |
print "Seconds: ", seconds | |
if seconds >= 10: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment