Standard library / math/big

big.Int.BitLen()

Returns bit length of absolute value, zero for zero. Expected stdout: '4\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Int) BitLen() int

Return Value

int

Returns bit length of absolute value, zero for zero.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(big.NewInt(-8).BitLen())}
Go Reference