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
+13.6k Golang : Strings comparison
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+25.6k Golang : Generate MD5 checksum of a file
+33.7k Golang : How to check if slice or array is empty?
+7.6k Golang : Rename part of filename
+8.5k Golang : How to check if input string is a word?
+8.3k Golang : Get final or effective URL with Request.URL example
+5.7k Golang : Detect words using using consecutive letters in a given string
+9.6k Golang : Extract or copy items from map based on value
+11.4k Golang : Intercept and process UNIX signals example
+16.6k Golang : Get IP addresses of a domain name
+6.1k Golang : Compound interest over time example