go 常量2

it2022-05-05  116

数值常量

数值常量是高精度的 _值_。

一个未指定类型的常量由上下文来决定其类型。

也尝试一下输出 needInt(Big) 吧。

package main import "fmt" const (     Big = 1 << 100     Small = Big >> 99 ) func needInt(x int) int { return x*10 + 1 } func needFloat(x float64) float64 {     return x * 0.1 } func main() {     fmt.Println(needInt(Small))     fmt.Println(needFloat(Small))     fmt.Println(needFloat(Big)) }  

go语言开发交流qq群 857263711

保持进步希望每个人都能找到自己喜欢的方式生活、工作。

转载于:https://www.cnblogs.com/songhuan999999/p/11187805.html


最新回复(0)