Take the base-2 logarithm of any positive number, with the floor, the ceiling and the bit length kept apart — because those are three different questions and all three get called log2. Base 2 is the one logarithm that comes out exact. A double is stored as a fraction multiplied by a power of two, s...
log₂ x = the number of doublings from 1 to x
Equivalently, how many times x can be halved before it reaches 1. Where that count comes out whole, this logarithm is exact — and computing it as ln x ÷ ln 2 is what throws the exactness away.
LOG BASE 2 · EXACT
10
x is exactly 2 to the power 10, so this answer carries no rounding at all — the exponent was already stored in the number.
FLOOR
10
CEILING
10
BIT LENGTH
11
This is the case where a logarithm is exact rather than approximated. A double is stored as a fraction times a power of two, so for a power of two the answer is already sitting in the number and only has to be read out. That is unique to base 2 — ln 8 and log₁₀ 8 are both irrational, and no amount of care recovers a clean value that was never there. Note that 1024 needs 11 binary digits to write down even though its logarithm is 10; those are two different questions and the panel below keeps them apart.
| Quantity | Value | What it answers |
|---|---|---|
| log₂ x | 10 | doublings from 1 to x |
| ⌊log₂ x⌋ | 10 | complete doublings, ignoring the remainder |
| ⌈log₂ x⌉ | 10 | bits to store x distinct values |
| bit length | 11 (10000000000) | binary digits needed to write x |
| ln x | 6.93147180559945 | the same number scaled by ln 2 |
| log₁₀ x | 3.01029995663981 | decimal digits, roughly |
| ln x / ln 2 | 10 | agrees here, but not always |
Floor, ceiling and bit length are three different questions. To store 1024 distinct values you need 10 bits. To write the number 1024 in binary you need 11 digits. And 10 is the position of its highest set bit. All three get called “log base 2” in conversation, and mixing them up is the most common source of off-by-one errors in code that allocates buffers or sizes hash tables.
THE HALVINGS
Count the rows and you have the logarithm. Each halving takes exactly one off it, which is why the answer for a power of two is a whole number and why the whole part is simply how many complete halvings fit.
Live calculation · updates as you type
Type any positive number into x. The logarithm appears immediately, and if x is a power of two the panel says so — that answer carries no rounding at all, because the exponent was already stored in the number.
Read the floor, ceiling and bit length as three separate answers. To store x distinct values you need the ceiling; to write x in binary you need the bit length; the floor is the position of its highest set bit. They are not interchangeable.
Watch the middle panel if you were about to compute this as ln x ÷ ln 2. It marks in red every value where that division disagrees with the dedicated routine, computed live rather than quoted, and the disagreements sit on the powers of two.
Drag the slider to step through the halvings. Counting the rows gives the whole part of the logarithm directly, and the green row at the end — the leftover between 1 and 2 — is what supplies the fractional part.
| Rule | Formula | What it is for |
|---|---|---|
| Definition | log₂ x = y means 2ʸ = x | How many doublings from 1 reach x, or how many halvings of x reach 1. |
| Change of base | log₂ x = ln x / ln 2 | True, but do not compute it this way: the division loses the exact integers. |
| Exact case | log₂(2ᵏ) = k | Exact for every representable k, because a double already stores its exponent. |
| Bits to write n | ⌊log₂ n⌋ + 1 | The number of binary digits. For 8 this is 4, since 8 is 1000. |
| Bits to store n values | ⌈log₂ n⌉ | Different question, often a different answer. For 8 distinct values, 3 bits. |
| Doubling | log₂(2x) = log₂ x + 1 | Each doubling adds exactly one. This is why log scales in base 2 are readable. |
| Product | log₂(ab) = log₂ a + log₂ b | Multiplication becomes addition, as in any base. |
| Binary search | ⌈log₂ n⌉ comparisons | The worst case for finding an item among n sorted ones by halving. |
| Information | log₂ n bits | The information in choosing one of n equally likely outcomes, measured in bits. |
| Inverse | 2^(log₂ x) = x | Round-tripped on this page and reported in units in the last place. |
24 Times Table
Calculate instantly →
Quadratic Equation Solver
Calculate instantly →
Logarithm Calculator
Calculate instantly →
Fraction Calculator
Calculate instantly →
Fraction Simplifier
Calculate instantly →
Linear Equation Solver
Calculate instantly →
25 Times Table
Calculate instantly →
26 Times Table
Calculate instantly →
27 Times Table
Calculate instantly →
Simultaneous Equations Solver (2×2)
Calculate instantly →
28 Times Table
Calculate instantly →
Exponent Calculator
Calculate instantly →
29 Times Table
Calculate instantly →
30 Times Table
Calculate instantly →
Times Tables Mega Calculator
Calculate instantly →
Square Root of 10
Calculate instantly →
Square Root of 1
Calculate instantly →
Square Root Mega
Calculate instantly →
Square Root of 2
Calculate instantly →
23 Times Table
Calculate instantly →
Last updated: August 3, 2026 · Computed with the dedicated base-2 routine, never by dividing two logs · checked against a 60-digit series