2020
12-22
12-22
golang int 转float 强转和高精度转操作
golangint转float方法一:强转:代码如下:import"fmt"funcmain(){varmoneyintmoney=1fmt.Println(float64(money)/float64(100))}输出结果:0.01方法二:高精度转:代码如下:import("fmt""math/big""strconv")funcmain(){totalAmount:=1numrator,_:=new(big.Float).SetPrec(uint(1024)).SetString(strconv.Itoa(totalAmount))denominator:=big.NewFloat(100)denominator1:=numrator.Quo(numrato...
继续阅读 >