Convert a bigint to a string in Go

Yster picture Yster · Aug 4, 2012 · Viewed 16k times · Source

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

Answer

cyberdelia picture cyberdelia · Aug 4, 2012

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

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