简体   繁体   English

div和mod in big.Float

[英]Div and Mod in big.Float

big.Int supports both Division and Modulo operations. big.Int支持除法和模运算。 Why division and modulo operations are not supported in big.Float? 为什么big.Float不支持除法和模运算? Is Quo() is different from division? Quo()是否不同于除法? Is there math.Mod(x, y float64) equivalent for big.Float 是否有big.Float的math.Mod(x,y float64)等效项

Division or quotient operation on integers and big integers produce integer value while on floats it produce float. 整数和大整数的除法或商运算产生整数值,而在浮点数上则产生浮点数。 That's why operations have different precision and mathematical sense. 这就是为什么运算具有不同的精度和数学意义。

var x, y int = 5, 3
z:=x/y    //give you 1

but

var x, y float32 = 5, 3
z:=x/y   //give you 1.6666666

Modulo or reminder operations didn't defined on floats because it's hard to elaborate what them can mean. 浮点数未定义模数或提醒操作,因为很难详细说明它们的含义。 Same with math/big 与数学相同/大

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM