×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.MaxUint32 Constant with Examples

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

math.MaxUint32 Constant

The MaxUint32 constant is an inbuilt constant of the math package which is used to get the highest (maximum) value that can be represented by a uint32 (unsigned int32).

The value of math.MaxUint32 constants is 1<<32 - 1 or 4294967295.

Syntax

int math.MaxUint32

Parameters

  • None

Return Value

The return type of math.MaxUint32 constant is int, it returns the highest (maximum) value that can be represented by a uint32.

Example 1

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

package main

import (
	"fmt"
	"math"
)

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

Output:

Type of math.MaxUint32 is int
Value of math.MaxUint32: 4294967295

Explanation:

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

Example 2

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

package main

import (
	"fmt"
	"math"
)

// creating function to
// return the value of MaxUint32.
func getMaxUint32() int {
	return math.MaxUint32
}

func main() {
	fmt.Println("Value of math.MaxUint32:", getMaxUint32())
}

Output:

Value of math.MaxUint32: 4294967295

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





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