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
+12.7k Golang : How to pass map to html template and access the map's elements
+15.6k Golang : Capture stdout of a child process and act according to the result
+6.5k Golang : Get YouTube playlist
+4.5k Golang : If else example and common mistake
+4.7k Fix yum-complete-transaction error
+5.8k Restart Apache or Nginx web server without password prompt
+6k Golang : Fibonacci number generator examples
+12.8k Golang : convert(cast) string to float value
+4.2k Unix/Linux : secure copying between servers with SCP command examples
+11.6k Golang : Transform comma separated string to slice example
+46.2k Golang : How to convert JSON string to map and slice
+8.7k Golang : List available AWS regions