Learn and Learn

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

GoLang – Find Binary Exponent – Ilogb() Function – Examples & Explanation

Ilogb() function is used to find the binary exponent of the given input (x – parameter) as an integer in Go language. The standard math library/package of Go programming language has Ilogb() function. The purpose of this function is to find the binary exponent of x as an integer.

Syntax of Ilogb() Function in Go Language

The syntax of Ilogb() function in Go Language is:

Note: float64 is a data type in Go language which has IEEE-754 64-bit floating-point numbers. And int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.
Special cases are:
Ilogb(±Inf) = MaxInt32
Ilogb(0) = MinInt32
Ilogb(NaN) = MaxInt32


Parameters of Ilogb() 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) Ilogb() 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 Ilogb() Function in Go Language

Ilogb() function will return the binary exponent of the given input(x – parameter) as an integer.


GoLang Ilogb() Function Example 1



GoLang Ilogb() Function Example 2



GoLang Ilogb() Function Example 3



LearnAndLearn.com © 2018 - All rights reserved