Created
January 25, 2017 13:00
-
-
Save petergloor/1eacd3ebcfc3e09ed578dd0d4f80cabe to your computer and use it in GitHub Desktop.
MaxInt, MinInt, MaxUint and MinUint in Go (golang)
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
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
finally, i kept forgetting the trick one. good bot !