Learn and Learn

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

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

Logb() function is used to find the binary exponent of the given input (x – parameter) in Go language. The standard math package of Go programming language has Logb() function.

Syntax of Logb() Function in Go Language

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

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

Logb() function will return the binary exponent of the given input(x – parameter).

 

GoLang Logb() Function Example 1


Output:
2

 

GoLang Logb() Function Example 2


Output:
2

 

GoLang Logb() Function Example 3


Output:
3

 

LearnAndLearn.com © 2018 - All rights reserved