Format an int64 as a string in a given base.
strconv.FormatInt returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters a to z for digit values >= 10.
This function is useful for converting numbers to binary, octal, hexadecimal, or other base representations.
For base 10, strconv.Itoa is a convenient shorthand for strconv.FormatInt(int64(i), 10).
| Name | Description | Optional |
|---|---|---|
i |
The int64 value to format. | No |
base |
The numeric base (2 to 36). | No |
fmt.Println(strconv.FormatInt(255, 16)) // ff
fmt.Println(strconv.FormatInt(255, 2)) // 11111111
fmt.Println(strconv.FormatInt(255, 8)) // 377