初学 go ,看教程 const的时候,发现 Big = 1 << 100 明显超出基础类型 uint64 了,于是想看下 Big 是什么类型
但是打印都 overflow 了遂有此疑问
const (
// 将 1 左移 100 位来创建一个非常大的数字
// 即这个数的二进制是 1 后面跟着 100 个 0
Big = 1 << 100
// 再往右移 99 位,即 Small = 1 << 1 ,或者说 Small = 2
Small = Big >> 99
)
func main() {
// cannot use Big (untyped int constant 1267650600228229401496703205376) as int value in argument to fmt.Printf (overflows)
fmt.Printf("T of Big %T\n", Big)
// cannot use Big (untyped int constant 1267650600228229401496703205376) as int value in argument to reflect.TypeOf (overflows)
fmt.Println("T of Big ", reflect.TypeOf(Big))
}