SoFunction
Updated on 2025-03-01

Implementation of int64 integer to string in go language

In go language, string(int) will treat int as the Unicode value of UTF-8 and convert it into corresponding characters. The standard library strconv is specially used to implement the mutual conversion of basic data types and their string representations.

package main

import (
    "fmt"
    "strconv"
)

func main() {
    // 64-bit integer    i := int64(123)

    // Integral to UTF-8 characters    s := string(i)
    (s) // {

    // Integer to string    s1 := (i, 10)
    (s1) // 123
}
package main

import (
    "fmt"
    "strconv"
)

func main() {
    //string to int    s := "1"
    i, _ := (s)
    (i)
    ("%T\r\n", i)

    //string to int64    s64 := "64"
    i64, _ := (s64, 10, 64)
    (i64)
    ("%T\r\n", i64)

    //int to string    s = (i)
    (s)

    //int64 to string    s64 = (i64, 10)
    (s64)

    //string to float32(float64)    sfloat := "1.23"
    f32, _ := (sfloat, 32/64)
    (f32)          // 1.23
    ("%T\r\n", f32) // float64

    // float to string    sf32 := (f32, 'E', -1, 32)
    (sf32)
    f64 := float64(100.23456) // 1.23E+00
    sf64 := (f64, 'E', -1, 64)
    (sf64) // 1.0023456E+02
    // 'b' (-ddddp±ddd, binary index)    // 'e' (-±dd, decimal index)    // 'E' (-±dd, decimal index)    // 'f' (-, no index)    // 'g' ('e':big index, 'f': other situations)    // 'G' ('E':Big Index, 'f':Other Situation)}

refer to

/pkg/

This is the end of this article about the implementation of the Go language int64 integer to string. For more related contents of the Go language int64 integer to string, please search for my previous articles or continue browsing the following related articles. I hope everyone will support me in the future!