https://cdn.jsdelivr.net/gh/tailwoodencat/CDN@main/uPic/2021/01/14/avatar-DoGrri.png

test code

精度问题 1 2 3 4 5 6 7 x := 74.96 y := 20.48 b := x - y fmt.Println(b) //output: 54.47999999999999 var a = 0.6 fmt.Println(a + 0.7) //output: 1.2999999999999998 出现浮点数不精确的原因是,浮点数储存至内存中时,2的-1、-2……-n次