Also available in: Español · Português · Français · العربية
Base converter
Binary, octal, decimal, hex and everything up to base 36 — including the fractional part, computed exactly, with repeating digits marked instead of truncated.
What is a base converter?
A base is how many digits you count with before you carry. Decimal has ten, binary two, hexadecimal sixteen — using a–z once the digits run out. The number itself never changes; only its spelling does. Twenty-five is 25 in decimal, 11001 in binary and 19 in hex, and all three are the same quantity.
Converting whole numbers is mechanical and every calculator gets it right. Fractions are where it becomes interesting, because whether a fraction has a tidy ending is not a property of the number at all — it is a property of the base you are writing it in.
This converter handles both, and computes the fractional part exactly. If the expansion repeats forever it says so and shows the cycle in brackets, rather than rounding to some arbitrary number of places and letting you assume that was the answer.
How to use the base converter
- Type your value. Digits 0–9 then a–z, with an optional minus sign and an optional fractional part. A digit the source base does not have is refused rather than quietly misread — 2 is not a binary digit, and treating it as one would give a confidently wrong answer.
- Set the two bases. Anything from 2 to 36, by typing a number or using the quick buttons for 2, 8, 10 and 16. Swap flips them, carrying the result across when it is exact.
- Read the result and what it tells you. Below the answer, the panel says whether the value ends in that base, how long the repeating cycle is if it does not, and which primes the base is built from — the fact that decides everything.
Whether a number ends is a fact about the base
One rule governs all of this: a fraction in lowest terms ends in base b exactly when every prime factor of its denominator also divides b. Decimal ends for tenths and eighths and fortieths because 10 = 2 × 5 and those denominators are built from 2s and 5s. It does not end for thirds, because 3 is not among them.
The consequence is more interesting than the rule. Binary, octal and hexadecimal have exactly one prime factor between them — 2 — so **they end on precisely the same fractions**. Converting a value from binary to hex can never turn a repeating expansion into a tidy one, checked here across five thousand denominators with not a single exception. That runs against the common feeling that hex is somehow finer or more precise than binary; for this purpose they are indistinguishable.
Counting the denominators from 1 to 10,000 that give an exact expansion: base 2 manages **14**, and so do base 8 and base 16 — the identical fourteen. Base 10 manages 48, better only because it brings in the prime 5. Base 12 manages 67, because 3 is a more useful prime to own than 5, which is the whole of the duodecimal argument in one number.
The example everybody has met without being told why is 0.1. In decimal it is exact by construction. In binary it is **0.0(0011)** — the four digits 0011 repeating forever — which is precisely why binary floating point cannot hold a tenth and why 0.1 + 0.2 famously misses 0.3. In hexadecimal it is 0.1(9), repeating for the same reason. Meanwhile a third, the standard example of a number that “doesn't come out”, is exactly **0.1** in base 3.
Honest limitations
A repeating cycle can be extremely long — as long as the denominator minus one — so a fraction with a large denominator can repeat for thousands of digits. This page computes up to two thousand and then stops, and says that it stopped rather than presenting a cut-off expansion as the whole answer.
Bases run from 2 to 36 because that is how far one digit per letter reaches. Base 37 would need a thirty-seventh symbol and there is no agreed one, so rather than invent notation the tool declines. The digits are case-insensitive, since the distinction carries no meaning here.
This is exact rational arithmetic, not floating point, so the value you type is the value converted. That also means it will disagree with a language's built-in conversion in a specific way: `parseFloat` on 0.1 gives you the nearest double, which is not a tenth, so a converter built on it would show you the binary expansion of that double rather than of the number you wrote. What you get here is the expansion of what you actually typed.
The engine carries 57 assertions. The two that matter are round trips rather than expected-output tables: every terminating expansion, written in another base and read back, must return the identical exact fraction; and every repeating expansion must reconstruct to the value it came from, using the standard formula computed independently in the test. The terminating rule is checked against a separate statement of the same fact — does some power of the base divide the denominator — over 3,200 cases.
Why is it free?
It is long division and long multiplication, running in your browser as you type. Nothing is uploaded, there is no account, and there is no limit.
If you want to see the same idea in ordinary decimals, the fraction calculator on this site marks repeating expansions the same way — it is the same technique with the base fixed at ten.