![]() ![]() Step 5 − Print the Integer type and the integer value using the fmt.Println() function. Step 5 − Convert the string to Int using ParseInt() Method. Step 4 − Display the type of variable using reflect.typeof() function. Step 1 − Import the package fmt, reflect and strconv If we wish to get the result in 32 bit float number then we have to specify the bitsize as 32 this makes the result convertible to 32 bit float number. This function returns the final result as a 64 bit integer type number and an error which can be printed on the screen if any problem occurs in the conversion process. This value specifies the size of the result. This function accepts two arguments one is the string that we wish to convert and other is a integer type value. ParseInt() function is used to convert strings to integer type values. Convert String Type Variable Into Int Syntax func ParseInt(s string, radix/base int, bitSize int) (i int64, err error) It decodes a string in the specified base (0, 2 to 36) and bit size (0, 64), and then it returns the equivalent result. ![]() ![]() Strings can be transformed into integer values using the ParseInt function. In this tutorial, we will learn how to convert string type variables into int in Go programming language.įor this task various types of string conversions are needed, to perform the conversions “strconv” package is imported in the go language program, ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |