-
-
Save wudi/2649f5a94299a53eeaf717cb502aba56 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