← All docs

log2()

Returns the base-2 logarithm of a number.

log2()

function log2(float $num): float

Returns the base-2 logarithm of a number.

Parameters:

  • $num (float)

Returns: float

Availability

  • Compiled (AOT): supported by the Elephc code generator.
  • eval() (magician interpreter): supported through a declarative interpreter builtin (crates/elephc-magician/src/interpreter/builtins/math/log2.rs).
  • Strict PHP mode: hidden - this builtin is an elephc extension with no PHP equivalent, so programs compiled with --strict-php treat the name as nonexistent, in compiled code and inside eval’d code.

No examples yet. Check examples/ and showcases/ for usage patterns.

Internals

For how log2 is implemented in the compiler, see the internals page.