package main import ( "fmt" "math/big" ) func main() { num := big.NewInt(1000) bits := num.BitLen() fmt.Println(bits) }
package main import ( "fmt" "math/big" ) func main() { num := big.NewInt(10000000000000000000000000000000000000000000000000000000000000000000000000) bits := num.BitLen() fmt.Println(bits) }Output: 363 In both examples above, we create a big.Int variable and then use the BitLen function to determine the number of bits required to represent the integer value. The first example demonstrates a small value, while the second example demonstrates a very large value.