Standard library / go/constant

go/constant.BitLen()

Count bits needed for the absolute integer magnitude; Unknown yields zero. Expected stdout: '4\n'.

Formal Syntax & Structure

go syntaxgo
func BitLen(x Value) int

Parameters & Attributes

NameTypeDescription
xValueInput constant or Go value as specified by the function.

Return Value

int

Count bits needed for the absolute integer magnitude; Unknown yields zero.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/constant")
func main() { fmt.Println(constant.BitLen(constant.MakeInt64(-8))) }
Go Reference