Skip to content

Instantly share code, notes, and snippets.

@KEINOS
Created July 3, 2023 10:37
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 KEINOS/b76cbfebd000f7810a11e106e2c4edd4 to your computer and use it in GitHub Desktop.
Save KEINOS/b76cbfebd000f7810a11e106e2c4edd4 to your computer and use it in GitHub Desktop.
[Golang] Example of float64 addition that doesn't sum up as expected. [IEEE 754]
package main
import "fmt"
// View it online: https://go.dev/play/p/GUuSXWcLUZ-
func main() {
// IEEE 754
a := 0.1
b := 0.2
fmt.Printf("%.064f\n", a+b)
// Output:
// 0.3000000000000000444089209850062616169452667236328125000000000000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment