在golang中使用big.Float进行一些计算后,我将精度设置为2。即使你的数字只是一个简单的10,在设置精度后它是8。packagemainimport("fmt""math/big")funcmain(){cost:=big.NewFloat(10)fmt.Println("COSTNOW",cost)perKWh:=big.NewFloat(0)cost.Add(cost,perKWh)fmt.Println("COST",cost.String())perMinute:=big.NewFloat(0)cost.Add(cost,perMinute)fmt.Println("
在golang中使用big.Float进行一些计算后,我将精度设置为2。即使你的数字只是一个简单的10,在设置精度后它是8。packagemainimport("fmt""math/big")funcmain(){cost:=big.NewFloat(10)fmt.Println("COSTNOW",cost)perKWh:=big.NewFloat(0)cost.Add(cost,perKWh)fmt.Println("COST",cost.String())perMinute:=big.NewFloat(0)cost.Add(cost,perMinute)fmt.Println("