Learn and Learn

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

GoLang – Ceil() Function – Examples & Explanation

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

Syntax of Ceil() Function in Go Language

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

 

Parameters of Ceil() Function in Go Language

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) Ceil() 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 Ceil() Function in Go Language

Ceil() function will return the least integer value greater than or equal to the given input(x – parameter).

 

GoLang Ceil() Function Example 1


Output:
2

 

GoLang Ceil() Function Example 2


Output:
-66

 

GoLang Ceil() Function Example 3


Output:
1

 

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