This site is supported by donations to The OEIS Foundation.

# Binary logarithm

The binary logarithm ${\displaystyle \log _{2}x}$ of a positive real number ${\displaystyle x\in \mathbb {R} ^{+}}$ is the exponent ${\displaystyle y}$ such that ${\displaystyle 2^{y}=x}$. Since ${\displaystyle \log 2^{y}=y\log 2=\log x}$, we have ${\displaystyle \log _{2}x={\frac {\log x}{\log 2}}}$, where ${\displaystyle \log }$ without the subscript is the natural logarithm (${\displaystyle \log 2}$ is approximately 0.69314718..., see A002162). For example, ${\displaystyle \log _{2}\pi }$ is approximately 1.65149612947... The binary logarithm of ${\displaystyle x}$ is an integer only when ${\displaystyle x}$ is an integer power of 2 (see A000079) or the reciprocal of an integer power of 2 (in the latter case a negative integer).
Occasionally, a couple other notations are used for the binary logarithm, specifically ${\displaystyle {\textrm {lg}}x}$ and ${\displaystyle {\textrm {ld}}x}$. However, for maximum clarity, it is best to use ${\displaystyle \log _{2}x}$.