Log2 v0.1.0

Source
Returns the base-2 logarithm.

Package: Math

Signature

func Log2(x: float64) -> float64;
func Log2(x: float32) -> float32;

Parameters

NameTypeDescription
xfloat64 / float32A non-negative value.

Returns

log₂(x), in the same precision as the argument. Log2(±0.0) is -Inf; Log2 of a negative value is a NaN; Log2(+Inf) is +Inf; a NaN propagates.

Example

import Math::Log2;

func Main() -> int {
    let a = Log2(8.0); // 3.0
    let b = Log2(1.0); // 0.0
    return 0;
}

See also

  • Math — the package overview
  • Log — natural logarithm
  • Log10 — base-10 logarithm
  • Exp2 — the inverse of Log2