func main() { fmt.Printf("math.MaxInt32: %d\n", math.MaxInt32) fmt.Printf("math.MinInt32: %d\n", math.MinInt32) var counter int32 = math.MaxInt32 counter++ fmt.Printf("math.MaxInt32 + 1 overflow: %d\n", counter) fmt.Printf("math.MaxInt32 in binary: %032b\n", math.MaxInt32) fmt.Printf("math.MaxInt32 + 1 overflow in binary: %032b\n", counter) var zero int32 = 0 fmt.Printf("0 of Int32 in binary: %032b\n", zero) var minusZero int32 = -0 fmt.Printf("-0 of Int32 in binary: %032b\n", minusZero) var one int32 = 1 fmt.Printf("1 of Int32 in binary: %032b\n", one) var minusOne int32 = -1 fmt.Printf("-1 of Int32 in binary: %032b\n", minusOne) }
zzh@ZZHPC:/zdata/Github/ztest$ go run main.go math.MaxInt32: 2147483647 math.MinInt32: -2147483648 math.MaxInt32 + 1 overflow: -2147483648 math.MaxInt32 in binary: 01111111111111111111111111111111 math.MaxInt32 + 1 overflow in binary: -10000000000000000000000000000000 0 of Int32 in binary: 00000000000000000000000000000000 -0 of Int32 in binary: 00000000000000000000000000000000 1 of Int32 in binary: 00000000000000000000000000000001 -1 of Int32 in binary: -0000000000000000000000000000001
Remember that Go provides a package to deal with large numbers: math/big. This might be an option if an int isn’t enough.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律