Home >Backend Development >Golang >How to convert int64 to string in go language

How to convert int64 to string in go language

藏色散人
藏色散人Original
2021-01-27 14:19:1827404browse

How to convert int64 to string in go language: 1. Create a go sample file; 2. Enter the code "i := int64(123)"; 3. Pass "s := strconv.FormatInt(i, 10 )" method to convert int64 to string.

How to convert int64 to string in go language

The operating environment of this article: Windows7 system, Go1.11.2, Dell G3 computer.

int64 to string

i := int64(123)
s := strconv.FormatInt(i, 10)

The second parameter is the base number, optional 2~36

Note: For unsigned integer, you can use FormatUint (i uint64, base int)

PS: Go language string, int, int64 conversion to each other

//string到int 
int,err:=strconv.Atoi(string) 
//string到int64 
int64, err := strconv.ParseInt(string, 10, 64) 
//int到string 
string:=strconv.Itoa(int) 
//int64到string 
string:=strconv.FormatInt(int64,10)
//string到float32(float64)
float,err := strconv.ParseFloat(string,32/64)
//float到string
string := strconv.FormatFloat(float32, 'E', -1, 32)
string := strconv.FormatFloat(float64, 'E', -1, 64)
// 'b' (-ddddp±ddd,二进制指数)
// 'e' (-d.dddde±dd,十进制指数)
// 'E' (-d.ddddE±dd,十进制指数)
// 'f' (-ddd.dddd,没有指数)
// 'g' ('e':大指数,'f':其它情况)
// 'G' ('E':大指数,'f':其它情况)

Recommendation: "golang tutorial

The above is the detailed content of How to convert int64 to string in go language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn