Golang : Convert(cast) bigint to string
Problem :
You want to convert(cast) a big integer value to string for display.
Solution :
Use big.Int.String() function to convert the big integer value to string. For example :
package main
import (
"fmt"
"math/big"
)
func main() {
bigInt := big.NewInt(123456789)
bigStr := bigInt.String()
fmt.Println(bigStr)
}
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+11.4k Golang : How to determine if a year is leap year?
+9.7k Swift : Convert (cast) Float to String
+17.7k Golang : Append content to a file
+16.9k Golang : How to make function callback or pass value from function as parameter?
+12.5k Golang : How to shuffle elements in array or slice?
+33.4k Golang : Convert date or time stamp from string to time.Time type
+5.9k Golang : How to execute code at certain day, hour and minute?
+6.3k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+14.5k Golang : Check if IP address is version 4 or 6
+4.8k Grep : How to grep for strings inside binary data
+5.6k Golang : Scanf function weird error in Windows
+14.5k Golang : Get future or past hours, minutes or seconds