Golang math.MinInt8 Constant with Examples

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

math.MinInt8 Constant

The MinInt8 constant is an inbuilt constant of the math package which is used to get the lowest (minimum) value that can be represented by an int8.

The value of math.MinInt8 constants is -1 << 7 or -128.

Syntax:

int math.MinInt8

Parameter(s):

  • None

Return Value:

The return type of math.MinInt8 constant is int, it returns the lowest (minimum) value that can be represented by an int8.

Example 1:

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

package main

import (
	"fmt"
	"math"
)

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

Output:

Type of math.MinInt8 is int
Value of math.MinInt8: -128

Explanation:

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

Example 2:

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

package main

import (
	"fmt"
	"math"
)

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

func main() {
	fmt.Println("Value of math.MinInt8:", getMinInt8())
}

Output:

Value of math.MinInt8: -128

Golang math Package Constants and Functions »





Comments and Discussions!

Load comments ↻






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