Math

Power of 2 calculator

Settings
Reset
Share
Save
Embed
Report a bug

Share calculator

Add our free calculator to your website

Please enter a valid URL. Only HTTPS URLs are supported.


Use as default values for the embed calculator what is currently in input fields of the calculator on the page.


Input border focus color, switchbox checked color, select item hover color etc.


Please agree to the Terms of Use.

Preview

Save calculator

Calculator Settings

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Share calculator

What is a power of 2 calculator?

A power of 2 calculator works with the expression 2n2^n — the number two multiplied by itself nn times. Powers of two appear everywhere in computing, because digital systems store and address information in binary, where each extra bit doubles the number of possible states.

This calculator runs in two directions. Given an exponent nn, it returns the value 2n2^n. Given a positive value vv, it returns the exponent n=log2vn = \log_2 v and tells you whether vv is an exact power of two.

Key concepts

  • Base — the number being raised to a power. Here the base is fixed at 2.
  • Exponent (n) — how many times the base is multiplied by itself. It can be zero, negative, or non-integer.
  • Power (2ⁿ) — the result of the exponentiation.
  • Base-2 logarithm — the inverse operation: log2v\log_2 v answers “to what exponent must 2 be raised to get vv?”.

How does the calculator work?

Use the Calculate selector to choose a direction. In “Value from exponent” mode you type nn and read off 2n2^n. In “Exponent from value” mode you type a positive vv and read off log2v\log_2 v, along with a note stating whether vv is an exact power of two.

Formulas

The value from an exponent:

value=2n\text{value} = 2^n

The exponent from a value:

n=log2v=lnvln2n = \log_2 v = \frac{\ln v}{\ln 2}

A value vv is an exact power of two when log2v\log_2 v is a whole number.

Worked examples

Example 1: value from exponent, n = 10

210=10242^{10} = 1024

Example 2: value from exponent, n = 0

20=12^{0} = 1

Example 3: value from exponent, n = 16

216=655362^{16} = 65536

Example 4: exponent from value, v = 256

log2256=8\log_2 256 = 8

Because 8 is a whole number, 256 is an exact power of two: 28=2562^8 = 256.

Example 5: exponent from value, v = 100

log21006.6439\log_2 100 \approx 6.6439

Since 6.6439 is not a whole number, 100 is not an exact power of two — it falls between 26=642^6 = 64 and 27=1282^7 = 128.

Practical uses

  • Computing and memory — kilobytes, megabytes, and gigabytes are commonly defined in powers of two (2102^{10}, 2202^{20}, 2302^{30}).
  • Networking — subnet sizes and address ranges are powers of two; see the binary to decimal calculator for the underlying conversions.
  • Algorithms — binary search, balanced trees, and divide-and-conquer methods scale with powers of two.
  • Scientific notation — for very large or very small results, switch to the exponential notation calculator.

Notes

  • The exponent may be negative: 23=0.1252^{-3} = 0.125.
  • A non-integer exponent is allowed: 20.5=21.41422^{0.5} = \sqrt{2} \approx 1.4142.
  • The base-2 logarithm is only defined for positive values, so vv must be greater than 0.
  • A value is flagged as an exact power of two only when its base-2 logarithm rounds to a whole number within a tiny tolerance.

Report a bug

This field is required.