ADVERTISEMENT
ADVERTISEMENT

Golang strconv.IntSize Constant with Examples

Golang | strconv.IntSize Constant: Here, we are going to learn about the IntSize constant of the strconv package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 05, 2021

strconv.IntSize Constant

The IntSize constant is an inbuilt constant of the strconv package which is used to get the size in bits of an int or uint value. The size of an int or uint depends on the compiler (machine) architecture, by using the IntSize constant we can get it.

Syntax:

int strconv.IntSize

Parameter(s):

  • None

Return Value:

The return type of strconv.IntSize constant is an int, it returns the size in bits of an int or uint value.

Example 1:

// Golang program to demonstrate the
// example of strconv.IntSize Constant

package main

import (
	"fmt"
	"strconv"
)

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

Output:

Type of strconv.IntSize is int
Value of strconv.IntSize: 64

Explanation:

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

Example 2:

// Golang program to demonstrate the
// example of strconv.IntSize Constant

package main

import (
	"fmt"
	"strconv"
)

// creating function to return
// the value of IntSize.
func getIntSize() int {
	return strconv.IntSize
}

func main() {
	fmt.Println("Value of strconv.IntSize:", getIntSize())
}

Output:

Value of strconv.IntSize: 64

Golang strconv Package »


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.