Math.Mod in Go returns the integer part instead of the remainder of the floating point

Golang math.Mod (10, 4) returns 2 - i.e. the integer part of the separation result 2.5 - but should not be a "remainder with a floating point", that is, 0.5?

+3
source share
1 answer

The result is correct. math.Mod returns the remainder, which in this case is really 2. This is equivalent to the% operator, but for floating point numbers.

+16
source

All Articles