Learn and Learn

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

GoLang – Find Greatest Integer Value – Floor() Function – Examples & Explanation

Floor() function is used to find the greatest integer value less than or equal to input (x – parameter) in Go language. The standard math package of Go programming language has Floor() function.

Syntax of Floor() Function in Go Programming

The syntax of Floor() 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:
Floor(±0) = ±0
Floor(±Inf) = ±Inf
Floor(NaN) = NaN

 

Parameters of Floor() Function in Go Programming

x – Where x is any Valid float64 Input value. This parameter is required.

 

Error Handling

If the x parameter is not a number (numeric value) Floor() function returns an error .
If there is no argument (x – input value) passes to the function, then the compiler will produce an error.

 

Return Value of Floor() Function in Go Programming

Floor() function will return the greatest integer value less than or equal to the given input(x – parameter).

 

GoLang Floor() Function Example 1


Output:
17

 

GoLang Floor() Function Example 2


Output:
5

 

GoLang Floor() Function Example 3


Output:
4294

 

Loading...
LearnAndLearn.com © 2018 - All rights reserved