×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.SmallestNonzeroFloat64 Constant with Examples

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

math.SmallestNonzeroFloat64 Constant

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

The value of math.SmallestNonzeroFloat64 constants is 4.9406564584124654417656879286822137236505980e-324 or 0x1p-1022 * 0x1p-52.

Syntax

float64 math.SmallestNonzeroFloat64

Parameters

  • None

Return Value

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

Example 1

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

package main

import (
	"fmt"
	"math"
)

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

Output:

Type of math.SmallestNonzeroFloat64 is float64
Value of math.SmallestNonzeroFloat64: 5e-324

Explanation:

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

Example 2

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

package main

import (
	"fmt"
	"math"
)

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

func main() {
	fmt.Println("Value of math.SmallestNonzeroFloat64:", getSmallestNonzeroFloat64())
}

Output:

Value of math.SmallestNonzeroFloat64: 5e-324

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.