Learn and Learn

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

GoLang – Show Positive Infinity – Inf() Function – Examples & Explanation

Inf() function is used to show the positive infinity if sign >= 0, negative infinity if sign < 0 of the given input (x – parameter) in Go language. The standard math package of Go programming language has Inf() function.

Syntax of Inf() Function in Go Language

The syntax of Inf() 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.

 

Parameters of Inf() Function in Go Language

x – Where x is any Valid int Input value (positive or negative). This parameter is required.

 

Error Handling

If the x parameter is not a number (numeric value) Inf() 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 Inf() Function in Go Language

Inf() function will return positive infinity if sign >= 0, negative infinity if sign < 0 of the given input(x – parameter).

 

GoLang Inf() Function Example 1


Output:
-Inf

 

GoLang Inf() Function Example 2


Output:
+Inf

 

GoLang Inf() Function Example 3


Output:
+Inf

 

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