Remainder()
regantewksbury12 total contributions
Published Sep 16, 2023
Contribute to Docs
The Remainder()
function returns the remainder of the division of two given values. The remainder may be a whole or a floating-point number.
Syntax
result := math.Remainder(num1, num2)
math.Remainder()
returns the whole or IEEE 754 floating-point remainder of num1 divided by num2, except in four special cases:
- If
num1
equals+-Inf
the function will returnNaN
. - If
num2
equals+-Inf
the function returnsnum1
. - If either argument is
NaN
the function will returnNaN
. - If
num2
equals0
the function will returnNaN
.
Example
This example divides two integer values and returns the remainder result
.
package mainimport ("fmt""math")func main() {result := math.Remainder(2, 35)fmt.Printf("%.1f\n", result)}
This will return:
2.0
Codebyte Example
The following example can be run and uses the math.Remainder()
function to return the remainder of two given values. The second call is an example of a special case and returns NaN
.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.