Browse the docs

log2

Returns the base 2 logarithm of a number.

Keyboard Maestro: LOG2

Details #

log2(x) takes exactly one argument and returns the base 2 logarithm. ceil(log2(n)) is how many bits it takes to count up to n.

Parameters #

Takes 1 argument. {{ log2(text) }}

Examples #

log2(8)
→ 3
ceil(log2(n))
→ 10
Sample variableValue
n1000

Gotchas #

  • Calling it with no argument or two arguments is an error: log2() takes 1 argument, got 2.

  • Anything that isn't a number is an error: log2() needs a number, got text. Numeric text such as "0.5" is accepted.

  • Zero and negative numbers have no logarithm; the step stops with log2() has no result for that number.