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
+7.1k Golang : Reverse text lines or flip line order example
+17k Golang : Find IP address from string
+19.9k Golang : Sort and reverse sort a slice of strings
+7.6k Golang : Executing and evaluating nested loop in html template
+11.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+16.2k Golang : Linked list example
+16.1k Golang : Iterate linked list example
+7.4k Golang : Generate Datamatrix barcode
+4.5k Golang : Stop goroutine without channel
+6.6k Golang : Shuffle strings array
+32.1k Golang : Converting a negative number to positive number
+9.5k Golang : How to transmit update file to client by HTTP request example