Skip to content

Instantly share code, notes, and snippets.

@inancgumus
Last active October 2, 2017 18:47
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 inancgumus/7ab3b8759df6232e2cc5063e412bdaba to your computer and use it in GitHub Desktop.
Save inancgumus/7ab3b8759df6232e2cc5063e412bdaba to your computer and use it in GitHub Desktop.
go ageOfUniverse overflows
package main
import (
"fmt"
)
// on 32-bit machines, it'll overflow
// on 64-bit machines, everything is fine
// use: uint64 instead.
func main() {
var ageOfUniverse int = 14e9 // 14e9 = 14 and 9 zeros which is 14 billions
fmt.Printf("`ageOfUniverse` is %d.\n", ageOfUniverse)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment