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
+37.7k Golang : Convert to io.ReadSeeker type
+6.5k Golang : How to convert strange string to JSON with json.MarshalIndent
+24.9k Golang : Convert(cast) string to uint8 type and back to string
+17.8k Golang : Read input from console line
+20.8k Golang : How to run Golang application such as web server in the background or as daemon?
+34k Golang : Get file last modified date and time
+10.1k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+11.5k Golang : HTTP response JSON encoded data
+4.4k Golang : Issue HTTP commands to server and port example
+4.5k Golang : Generate Interleaved 2 inch by 5 inch barcode
+14.7k Golang : How to reverse elements order in map ?
+12.1k Golang : How to get a user home directory path?