Golang 的 math.Mod(10, 4) 返回 2 —— 即。除法结果 2.5 的整数部分——但它不应该是“浮点余数”,即 0.5 吗?
最佳答案
结果正确。 math.Mod返回余数,在这种情况下实际上是 2。它等效于 % 运算符,但适用于 float 。
关于floating-point - Go 中的 math.Mod 返回整数部分而不是浮点余数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10650095/