Binary Logarithm Calculator
Enter a positive binary number to calculate its base-2 logarithm. See the log₂ value, decimal equivalent, nearest powers of two, and whether the input is an exact power of 2.
What Is a Binary Logarithm?
A binary logarithm is a logarithm with base 2. It answers the question: what exponent must 2 be raised to in order to produce a particular number?
Binary logarithms are written as log₂(x). For example,
log₂(8) = 3 because 2³ = 8. Since decimal 8 is
1000₂, we can also write log₂(1000₂) = 3.
This Binary Logarithm Calculator accepts the input itself in base 2. It converts the numerical value as needed and calculates its base-2 logarithm.
How to Calculate log₂ of a Binary Number
What Is log₂(1000₂)?
Binary 1000₂ equals decimal 8. Since 2 raised to the third
power equals 8, its binary logarithm is exactly 3.
What Is log₂(101₂)?
Binary 101₂ equals decimal 5. Five is not an exact power of
two, so its binary logarithm is not a whole number.
Common Binary Logarithm Values
| Binary Input | Decimal Value | Binary Logarithm |
|---|---|---|
| 1 | 1 | 0 |
| 10 | 2 | 1 |
| 100 | 4 | 2 |
| 1000 | 8 | 3 |
| 10000 | 16 | 4 |
| 100000 | 32 | 5 |
| 1000000 | 64 | 6 |
| 10000000 | 128 | 7 |
| 100000000 | 256 | 8 |
| 10000000000 | 1024 | 10 |
Binary Logarithms of Values Below 1
Binary logarithms can also be negative. This happens when the input is greater than zero but less than one.
For example, 0.01₂ equals one quarter. Since one quarter is
2⁻², its binary logarithm is exactly −2.
Why Powers of Two Give Integer Logarithms
When the input is exactly a power of two, its base-2 logarithm is simply the exponent. This makes powers of two especially easy to recognize in binary.
Positive integer powers of two appear as a single 1 followed
by zeros. For example, 100000₂ equals 32, which is
2⁵. Therefore its binary logarithm is 5.
Floor and Ceiling of a Binary Logarithm
When a number is not an exact power of two, it lies between two adjacent powers. Those boundaries are useful in many computer-science calculations.
For 101₂ = 5, the neighboring powers are 4 and 8. Therefore
the logarithm lies between 2 and 3.
Why log₂ Is Important in Computer Science
Base-2 logarithms help determine approximately how many binary digits are needed to represent positive integers.
The logarithmic complexity of binary search is commonly expressed as O(log₂ n).
Balanced trees and other structures frequently have heights related to the binary logarithm of their element count.
Repeated halving or doubling naturally produces logarithmic relationships with base 2.
Powers of two occur throughout digital storage, address spaces, and hardware organization.
Base-2 logarithms are used when information is measured in bits.
Binary Logarithm and Number of Bits
For a positive integer n, the number of bits required for its
ordinary unsigned binary representation is related directly to its
base-2 logarithm.
For example, decimal 13 is 1101₂. Since
log₂(13) is between 3 and 4, its floor is 3. Adding one gives
a bit length of 4, matching the four digits in 1101₂.
Important Input Rules
The input must be positive
A real logarithm is not defined for zero or negative numbers. Therefore the binary value must be greater than zero.
Use binary digits only
The input may contain 0, 1, and one optional binary point. Decimal digits such as 2 through 9 are not valid binary digits.
Non-power results are approximate
Most positive numbers are not exact powers of two. Their logarithms are irrational or non-terminating values and are therefore displayed as decimal approximations.