Golang : Find the length of big.Int variable example
There is a chance that you will ever need to get the length of big.Int
variable and below is a simple example on how to count the length of a big.Int
variable.
package main
import (
"fmt"
"math/big"
)
func main() {
// base 10
bigInteger := new(big.Int)
bigInteger.SetString("100000000000000000L", 10) //18
fmt.Println("Value : ", bigInteger)
fmt.Println("Length : ", len(bigInteger.Text(10)))
}
Output:
Value : 100000000000000000
Length : 18
Reference:
https://www.socketloop.com/tutorials/golang-convert-string-or-integer-to-big-int-type
See also : Golang : Calculate Relative Strength Index(RSI) example
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
+3.7k Nginx and PageSpeed build from source CentOS example
+12.2k Golang : Verify token from Google Authenticator App
+12.3k Golang : Strings comparison
+9.4k Golang : How to transmit update file to client by HTTP request example
+7.8k Golang : Build and compile multiple source files
+7.8k Golang : Apply Histogram Equalization to color images
+16.3k Golang : Upload/Receive file progress indicator
+4.8k Golang : Find change in a combination of coins example
+11.3k Swift : Convert (cast) Int or int32 value to CGFloat
+18.1k Golang : Delete item from slice based on index/key position
+25.2k Golang : Force your program to run with root permissions
+6.4k Golang : How to convert strange string to JSON with json.MarshalIndent