Skip to content

Instantly share code, notes, and snippets.

@sarunw
Created October 7, 2018 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarunw/cc110c6e52de87a812909b359f239fad to your computer and use it in GitHub Desktop.
Save sarunw/cc110c6e52de87a812909b359f239fad to your computer and use it in GitHub Desktop.
Float and Double error
var float: Float = 0.01
var floatSum: Float = 0
for i in 0..<100 {
floatSum += float
}
floatSum
floatSum == 1
var double: Double = 0.01
var doubleSum: Double = 0
for i in 0..<100 {
doubleSum += double
}
doubleSum
doubleSum == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment