Search code examples
stringgointegerbigint

Convert a bigint to a string or integer in Go


How do one convert a big int to a string (or integer) in Golang?

bigint := big.NewInt(123) //This is what I have
bigstr = "123" //This is what I want

Solution

  • Just use the String method : http://golang.org/pkg/math/big/#Int.String

    bigint := big.NewInt(123)
    bigstr := bigint.String()