Standard library / math

math.Log2()

Base-two logarithm. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func Log2(x float64) float64

Parameters & Attributes

NameTypeDescription
xfloat64First input operand (or sole input if unary).

Return Value

float64

Base-two logarithm.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math")
func main() {  fmt.Println(math.Log2(8))}
Go Reference