Power of 2 Calculator

Compute 2 raised to any exponent (2^n), and check whether a number is a power of two — including its nearest lower and upper powers of two.

Quick Facts

2^0
= 1
Any nonzero number raised to the power 0 equals 1.
2^10
= 1,024
The basis for "kilo" in computing: 1 KB = 2^10 bytes.
Power-of-two test
Halve repeatedly to 1
Equivalently, log2(N) is a whole number.

Your Results

Calculated
2^n
-
2 raised to the exponent n
Is N a power of 2?
-
Repeated-halving test on N
Previous power of 2
-
Largest 2^k ≤ N
Next power of 2
-
Smallest 2^k ≥ N

Ready

Enter an exponent n and a number N, then press Calculate.

How the Power of 2 Calculator works

A power of two is any number of the form 2^n — 2 multiplied by itself n times, such as 2^5 = 32. The idea extends beyond positive whole numbers using the standard rules of exponents: 2^0 = 1, negative exponents flip to a reciprocal (2^-n = 1/2^n), and fractional exponents give roots (2^(1/2) = √2). This calculator does two things at once: it raises 2 to any exponent you enter, and it checks whether a separate number N is itself a power of two, reporting the nearest power of two below and above it.

Formula and method

The first result simply evaluates 2^n = 2 × 2 × ... × 2 (n factors) for positive integers, and more generally 2^n = e^(n·ln 2) for any real exponent n, which is how the calculator handles zero, negative, and decimal exponents consistently. The second result tests N for the power-of-two property: divide N by 2 repeatedly; if you land on exactly 1 with no remainder at any step, N = 2^k for some whole number k. The calculator also reports the largest power of two that is ≤ N and the smallest one that is ≥ N by walking that same halving/doubling sequence, so you can see how far N sits from the nearest binary "round number."

Why powers of two matter in computing

Binary digital systems count in base 2, so memory and storage capacities are naturally powers of two: 1 KB = 2^10 = 1,024 bytes, 1 MB = 2^20 bytes, and 1 GB = 2^30 bytes. Array sizes, hash-table capacities, and buffer lengths are frequently chosen as powers of two because it lets hardware use fast bit-shift operations instead of slower division and lines addresses up cleanly with memory pages.

Common sources of error

  • Confusing 2^n with n^2: 2^10 = 1,024 (2 multiplied by itself 10 times), while 10^2 = 100 (10 multiplied by itself twice) — the base and exponent are not interchangeable.
  • Forgetting negative exponents are fractions: 2^-4 = 1/16 = 0.0625, not -16.
  • Assuming every even number is a power of two: 12 and 24 are even but not powers of two, since dividing them by 2 repeatedly does not land exactly on 1 (12 → 6 → 3, which is odd and not 1).

Applications

Beyond computer memory sizing, powers of two show up in doubling-time growth models (population, compound processes with a fixed doubling period), binary search and divide-and-conquer algorithms (which repeatedly halve a problem size), tournament brackets (which need a power-of-two number of entrants to avoid byes), and music/audio sampling and buffer sizes.

Frequently Asked Questions

What does 2 to the power of n mean?
2 to the power of n (written 2^n) means 2 multiplied by itself n times, such as 2^5 = 2×2×2×2×2 = 32. The definition extends to zero, negative, and fractional exponents through the standard rules of exponents: 2^0 = 1, 2^-n = 1/2^n, and 2^(1/2) = √2.
How can I tell if a number is a power of two?
Divide the number by 2 repeatedly. If you reach exactly 1 with no remainder at any step, it is a power of two — for example 64 → 32 → 16 → 8 → 4 → 2 → 1. Programmers often use the equivalent bitwise test N & (N-1) === 0 for positive integers.
What is 2 to the power of 0, and can exponents be negative?
Any nonzero number raised to the power 0 equals 1, so 2^0 = 1. Negative exponents represent reciprocals: 2^-n = 1/2^n, so 2^-3 = 1/2^3 = 1/8 = 0.125.
Why are powers of two important in computing?
Computers store data in binary, so memory and storage sizes are naturally powers of two: 1 KB = 2^10 = 1,024 bytes, 1 MB = 2^20 bytes, and 1 GB = 2^30 bytes. Arrays, buffers, and hash tables are also often sized to powers of two because it makes memory addressing and indexing more efficient.