Skip to content

Instantly share code, notes, and snippets.

@wudi
Forked from petergloor/main.go
Created January 8, 2018 03:06
Show Gist options
  • Save wudi/2649f5a94299a53eeaf717cb502aba56 to your computer and use it in GitHub Desktop.
Save wudi/2649f5a94299a53eeaf717cb502aba56 to your computer and use it in GitHub Desktop.
MaxInt, MinInt, MaxUint and MinUint in Go (golang)
package main
import "fmt"
// Constant definitions
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1
func main() {
fmt.Println("Integer range on this computer")
fmt.Println("MinUint:", MinUint)
fmt.Println("MaxUint:", MaxUint)
fmt.Println("MinInt:", MinInt)
fmt.Println("MaxInt:", MaxInt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment