Home

log2N

Log2n refers to the logarithm of a positive number n with base 2. It is written as log base 2 of n, or log2 n, and is the exponent x that satisfies 2^x = n. Like other logarithms, log2 n is the inverse of the exponential function 2^x and is defined for n > 0. If n is a power of two, log2 n is an integer; otherwise it is a non-integer real number.

Key properties include that log2 n is strictly increasing on (0, infinity) and maps (0, infinity) to

In practice, log2 n is widely used in computer science to analyze algorithmic complexity, often appearing in

(-infinity,
infinity).
Its
derivative
with
respect
to
n
is
1/(n
ln
2).
The
identity
log2(2^k)
=
k
holds
for
any
real
k.
The
change
of
base
formula
gives
log2
n
=
log
n
/
log
2
for
any
other
base
of
the
logarithm.
For
integer
n
≥
1,
floor(log2
n)
is
the
position
of
the
highest
set
bit
in
the
binary
representation,
and
the
bit-length
of
n
is
floor(log2
n)
+
1.
time
bounds
that
are
O(log
n).
It
also
relates
to
the
amount
of
information
in
binary
systems,
where
logarithms
base
2
measure
information
content.
When
applying
log2
n
to
discrete
contexts,
rounding
is
common;
for
example,
floor
or
ceil
functions
are
used
to
obtain
integer
results
from
non-integer
logarithms.