Log Base 2 — Binary Logarithm, Values & Examples
Log Base 2 — Binary Logarithm, Values & Examples
TL;DR
Log base 2 of a number is the power to which 2 must be raised to produce that number — so ( \log_2 8 = 3 ) because ( 2^3 = 8 ). This article covers what log base 2 (the binary logarithm) means, how to compute it by hand and with the change-of-base formula, a value table, its properties, where it powers computer science, and the slips to avoid.
What Is Log Base 2?
Log base 2 of a number ( x ), written ( \log_2 x ), is the exponent you put on 2 to get ( x ). In symbols:
[ \log_2 x = y \Longleftrightarrow 2^y = x. ]
So ( \log_2 8 = 3 ) because ( 2^3 = 8 ), and ( \log_2 32 = 5 ) because ( 2^5 = 32 ). The logarithm and the exponent are the same fact looked at from opposite ends — one asks "what is ( 2^3 )?", the other asks "2 to what gives 8?". That two-way relationship is the whole of log to exponential form conversion.
Log base 2 is also called the binary logarithm, sometimes written ( ext{lb} ) or ( ext{lg} ). The "binary" name is a hint about where it earns its keep — anything built on two states, on/off, 0/1.
How Do You Calculate Log Base 2?
There are two cases, and which one you are in decides the method.
When ( x ) is a power of 2, read the answer straight off. Ask how many times you multiply 2 to reach ( x ):
[ \log_2 16 = 4 \quad \text{since} \quad 2^4 = 16. ]
No calculator needed. The powers of 2 — 1, 2, 4, 8, 16, 32, 64, 128, 256 — are worth knowing on sight.
When ( x ) is not a power of 2, use the change-of-base formula. It states:
[ \log_2 x = \frac{\ln x}{\ln 2} = \frac{\log x}{\log 2}. ]
For example,
[ \log_2 10 = \frac{\ln 10}{\ln 2} \approx \frac{2.3026}{0.6931} \approx 3.32. ]
Log Base 2 Value Table
For the exact powers of 2, the binary logarithm is a clean whole number. This table is the one to memorise.
| ( x ) | ( \log_2 x ) | Because |
|---|---|---|
| 1 | 0 | ( 2^0 = 1 ) |
| 2 | 1 | ( 2^1 = 2 ) |
| 4 | 2 | ( 2^2 = 4 ) |
| 8 | 3 | ( 2^3 = 8 ) |
| 16 | 4 | ( 2^4 = 16 ) |
| 32 | 5 | ( 2^5 = 32 ) |
| 64 | 6 | ( 2^6 = 64 ) |
| 128 | 7 | ( 2^7 = 128 ) |
| 256 | 8 | ( 2^8 = 256 ) |
| 1024 | 10 | ( 2^{10} = 1024 ) |
Two boundary facts close the table: ( \log_2 1 = 0 ) (anything to the power 0 is 1), and ( \log_2 0 ) is undefined — no power of 2 ever reaches 0.
What Are the Properties of Log Base 2?
Log base 2 obeys the same laws as every logarithm — they just carry a subscript 2. These come straight from the logarithm rules, specialised to base 2.
- Product rule: ( \log_2(MN) = \log_2 M + \log_2 N ) — a product turns into a sum.
- Quotient rule: ( \log_2 \left( \frac{M}{N} \right) = \log_2 M - \log_2 N ) — a quotient turns into a difference.
- Power rule: ( \log_2(M^p) = p, \log_2 M ) — an exponent comes down front.
- Base of itself: ( \log_2 2 = 1 ), and more generally ( \log_2 2^k = k ).
- Log of 1: ( \log_2 1 = 0 ) in every base.
Examples of Log Base 2
Example 1
Find ( \log_2 64 ).
[ \log_2 64 = 6 ] because ( 2^6 = 64. )
Final answer: 6.
Example 2
Find ( \log_2 12 ) — and watch the tempting wrong move first.
Wrong attempt: ( \log_2 12 = 2 \times 3 = 6. ) Check it: ( 2^6 = 64 ), nowhere near 12. The answer cannot be 6.
Correct: ( \log_2 12 = \log_2(4 \times 3) = \log_2 4 + \log_2 3 = 2 + \log_2 3. )
( \log_2 3 \approx 1.585 ), so ( \log_2 12 \approx 3.585. )
Final answer: ( \log_2 12 \approx 3.585. )
Example 3
Find ( \log_2 \frac{1}{8} ).
( 1/8 = 2^{-3} ), so ( \log_2 \frac{1}{8} = -3. )
Final answer: -3.
Example 4
Use the change-of-base formula to find ( \log_2 50 ).
( \log_2 50 = \frac{\ln 50}{\ln 2} \approx 5.64. )
Final answer: ( \log_2 50 \approx 5.64. )
Example 5
Simplify ( \log_2 8 + \log_2 4 ) using the product rule.
[ \log_2 8 + \log_2 4 = \log_2(8 \times 4) = \log_2 32 = 5. ]
Final answer: 5.
Example 6
How many bits are needed to store a number from 0 to 999?
Storing ( N ) distinct values needs ( \lceil \log_2 N \rceil ) bits — the binary logarithm rounded up. With 1000 values:
[ \log_2 1000 = \frac{\ln 1000}{\ln 2} \approx 9.97, \qquad \lceil 9.97 \rceil = 10. ]
Final answer: 10 bits.
Why Log Base 2 Runs Through Computing
Log base 2 is the native tongue of computers, measuring counting bits and powering algorithms. It’s crucial in areas like:
- Bits to represent a number. A value up to N needs ( \lceil \log_2 N \rceil ) bits.
- Algorithm speed. Binary search, balanced search trees, and merge sort run in time proportional to ( \log_2 n ).
- Information theory. Claude Shannon measured information in bits with binary logarithm at its core.
Where Students Trip Up on Log Base 2
Common mistakes include:
- Forgetting the base and using base 10 by reflex.
- Taking the log of zero or a negative number.
- Multiplying logs instead of adding them.
The Short Version
- Log base 2 of ( x ) is the power of 2 that gives ( x ).
- For powers of 2, read the answer off the value table; for other numbers, use the change of base.
- The product, quotient, and power rules apply with a subscript 2.
- The most common mistake is forgetting the base.
- Log base 2 measures information in bits and the step-count of halving algorithms.
Practice These Before Moving On
- Find ( \log_2 128 ).
- Find ( \log_2 \frac{1}{16} ).
- Use change of base to estimate ( \log_2 20 ).
- Simplify ( \log_2 16 - \log_2 2 ).
- How many bits store a number from 0 to 500?
Answers: 1. 7, 2. -4, 3. ≈ 4.32, 4. 3, 5. 9 bits.