ADVERTISEMENT
ADVERTISEMENT

Golang math.SmallestNonzeroFloat32 Constant with Examples

Golang | math.SmallestNonzeroFloat32 Constant: Here, we are going to learn about the SmallestNonzeroFloat32 constant of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 26, 2021

math.SmallestNonzeroFloat32 Constant

The SmallestNonzeroFloat32 constant is an inbuilt constant of the math package which is used to get the smallest positive, non-zero value of float32 type.

The value of math.SmallestNonzeroFloat32 constants is 1.401298464324817070923729583289916131280e-45 or 0x1p-126 * 0x1p-23.

Syntax:

float64 math.SmallestNonzeroFloat32

Parameter(s):

  • None

Return Value:

The return type of math.SmallestNonzeroFloat32 constant is float64, it returns the smallest positive, non-zero value of float32 type.

Example 1:

// Golang program to demonstrate the
// example of math.SmallestNonzeroFloat32 Constant

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Printf("Type of math.SmallestNonzeroFloat32 is %T\n", math.SmallestNonzeroFloat32)
	fmt.Println("Value of math.SmallestNonzeroFloat32:", math.SmallestNonzeroFloat32)
}

Output:

Type of math.SmallestNonzeroFloat32 is float64
Value of math.SmallestNonzeroFloat32: 1.401298464324817e-45

Explanation:

In the above program, we imported the math package to use the math.SmallestNonzeroFloat32 constant, then printed the type and value of the math.SmallestNonzeroFloat32 constant.

Example 2:

// Golang program to demonstrate the
// example of math.SmallestNonzeroFloat32 Constant

package main

import (
	"fmt"
	"math"
)

// creating function to
// return the value of SmallestNonzeroFloat32.
func getSmallestNonzeroFloat32() float64 {
	return math.SmallestNonzeroFloat32
}

func main() {
	fmt.Println("Value of math.SmallestNonzeroFloat32:", getSmallestNonzeroFloat32())
}

Output:

Value of math.SmallestNonzeroFloat32: 1.401298464324817e-45

Golang math Package Constants and Functions »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.