Remainder()
function is used to find the IEEE 754 floating-point remainder of x/y
in Go language. The standard math package of Go programming language has Remainder()
function.
Syntax of Remainder()
Function in Go Language
The syntax of
Remainder()
function in Go Language is:
func Remainder(x, y float64) float64
Note: float64
is a data type in Go language which has IEEE-754 64-bit floating-point numbers.
Special cases are:
Remainder(±Inf, y) = NaN
Remainder(NaN, y) = NaN
Remainder(x, 0) = NaN
Remainder(x, ±Inf) = x
Remainder(x, NaN) = NaN
Parameters of Remainder()
Function in Go Language
x, y
– Where x
and y
are Valid float64
Input values. These parameters are required.
Error Handling
If the
If there is no argument (
x
or y
parameters are not numbers (numeric values) Remainder()
function returns an error
.If there is no argument (
x
or y
– input value) passes to the function, then the compiler will produce an error
.
Return Value of Remainder()
Function in Go Language
Remainder()
function will return the IEEE 754 floating-point remainder of x/y
.
GoLang Remainder()
Function Example 1
package main import "fmt" import "math" func main() { var x float64 x = math.Remainder(-11, 2) fmt.Println(x) }
Output:
1
GoLang Remainder()
Function Example 2
package main import "fmt" import "math" func main() { var x float64 x = math.Remainder(2, 13) fmt.Println(x) }
Output:
2
GoLang Remainder()
Function Example 3
package main import "fmt" import "math" func main() { var x float64 x = math.Remainder(-15, -6.21) fmt.Println(x) }
Output:
-2.58