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
+8.2k Golang : Ackermann function example
+10.5k Golang : Simple File Server
+11.7k Golang : Convert decimal number(integer) to IPv4 address
+6.1k Javascript : Generate random key with specific length
+21.9k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+33.7k Golang : Create x509 certificate, private and public keys
+26.4k Golang : Encrypt and decrypt data with AES crypto
+12.9k Golang : List objects in AWS S3 bucket
+10.3k Golang : Resolve domain name to IP4 and IP6 addresses.
+8.4k Golang : Set or add headers for many or different handlers
+5.7k Golang : Shuffle array of list
+10.1k Golang : Wait and sync.WaitGroup example