Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

GoLang – Find Floating Point Remainder – Remainder() Function – Examples & Explanation

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:

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 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


Output:
1

 

GoLang Remainder() Function Example 2


Output:
2

 

GoLang Remainder() Function Example 3


Output:
-2.58

 

LearnAndLearn.com © 2018 - All rights reserved