×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.MaxFloat64 Constant with Examples

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

math.MaxFloat64 Constant

The MaxFloat64 constant is an inbuilt constant of the math package which is used to get the largest finite value of float64 type.

The value of math.MaxFloat64 constants is 1.79769313486231570814527423731704356798070e+308 or 0x1p1023 * (1 + (1 - 0x1p-52)).

Syntax

float64 math.MaxFloat64

Parameters

  • None

Return Value

The return type of math.MaxFloat64 constant is float64, it returns the largest finite value of float64 type.

Example 1

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

package main

import (
	"fmt"
	"math"
)

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

Output:

Type of math.MaxFloat64 is float64
Value of math.MaxFloat64: 1.7976931348623157e+308

Explanation:

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

Example 2

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

package main

import (
	"fmt"
	"math"
)

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

func main() {
	fmt.Println("Value of math.MaxFloat64:", getMaxFloat64())
}

Output:

Value of math.MaxFloat64: 1.7976931348623157e+308

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





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