Learn and Learn

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

GoLang – find the minimum value – Min() Function – Examples & Explanation

Min() function is used to find the smaller of the given inputs (x or y – parameters) in Go language. The standard math package of Go programming language has Min() function.

Syntax of Min() Function in Go Language

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

 

Parameters of Min() Function in Go Language

x – Where x or y is any Valid float64 Input value. These parameters are required.

 

Error Handling

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

 

Return Value of Min() Function in Go

Min() function will return the smaller value of the given inputs (x or y – parameters).

 

GoLang Min() Function Example 1


Output:
-6

 

GoLang Min() Function Example 2


Output:
0

 

GoLang Min() Function Example 3


Output:
-5

 

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