Standard library / strconv

strconv.FormatInt()

Formats a signed int64 in base 2–36 using lowercase digits; invalid bases panic. Negative values receive a minus sign. Expected stdout: '-1f\n'.

Formal Syntax & Structure

go syntaxgo
func FormatInt(i int64, base int) string

Parameters & Attributes

NameTypeDescription
iint64Integer value to encode.
baseintOutput radix 2–36.

Return Value

string

Encoded representation.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  fmt.Println(strconv.FormatInt(-31, 16))}
Go Reference