Float → Exact Fraction — What an IEEE-754 Double Really Stores
Convert a decimal number to the exact rational fraction its IEEE-754 double actually stores, its full decimal expansion, and the simplest fraction that rounds to the same double. Works the other way too: turn a/b into a decimal and flag when it can’t be stored exactly. Live, in your browser, with BigInt-exact arithmetic.
How to Use
- Type a decimal number (e.g. 0.1, 3.14159 or -2.5) into the top box.
- Read the exact fraction the double stores — numerator over denominator, fully reduced — and its complete decimal expansion.
- See the simplest fraction that still rounds to the very same double — usually the value you actually meant.
- Switch to the Fraction → Decimal tab to enter a/b and see its decimal, flagged if it cannot be represented exactly in binary.
- Click any value to copy it.
Every double is secretly an exact fraction
A 64-bit IEEE-754 double does not store decimal digits — it stores a binary fraction: a 53-bit integer (the significand) multiplied by a power of two. That makes every finite double an exact rational number whose denominator is always a power of two. So when you type 0.1, the computer cannot store one tenth; the closest it can do is 3602879701896397 / 36028797018963968, which is a hair larger than 0.1. This tool pulls the actual bits of the double (via DataView.getBigUint64), reconstructs that exact fraction, reduces it with BigInt, and shows you the full, untruncated decimal expansion — the real number hiding behind your literal.
Exact value vs. the value you meant
The exact fraction is precise but unwieldy, so the tool also finds the simplest fraction that rounds back to the very same double — the rational with the smallest denominator whose nearest double is identical to your input. For 0.1 that simplest fraction is just 1/10: the value you almost certainly meant before binary rounding intervened. It is computed with a continued-fraction best-approximation walk over the stored value’s convergents (the Stern–Brocot search behind “shortest round-tripping” floats). Numbers like 0.5, 0.25 and 0.75 are different — they are exact powers-of-two fractions, so the exact and simplest forms agree (1/2, 1/4, 3/4).
Going the other way
The reverse tab takes a fraction a/b and computes its decimal. A fraction is stored exactly by a double only when its reduced denominator is a power of two and it fits in 53 bits of precision — so 3/4 and 1/8 are exact, while 1/3, 1/10 and 22/7 are not. When a fraction can’t be represented exactly, the tool flags it and shows the nearest double’s value, so you can see precisely how far off the stored number will be. All of this is exact BigInt arithmetic done in your browser, never rounded and never uploaded.
Quick reference
About the Float → Exact Fraction — What an IEEE-754 Double Really Stores
Need a hand with everyday tasks? The Float → Exact Fraction — What an IEEE-754 Double Really Stores does the work for you — free, and right here in your browser. Convert a decimal number to the exact rational fraction its IEEE-754 double actually stores, its full decimal expansion, and the simplest fraction that rounds to the same double. Works the other way too: turn a/b into a decimal and flag when it can’t be stored exactly. Live, in your browser, with BigInt-exact arithmetic.
How it works
Enter a number and choose your units — the converted value shows instantly. Everything runs locally, so nothing you type leaves your device. Double-check the direction of the conversion and you are set.
Want the deeper story? The Knowledge Base explains the ideas behind the tools in more detail.
Frequently Asked Questions
Why isn’t 0.1 stored as 1/10?
A double is a binary fraction: a 53-bit integer times a power of two. Tenths are not a power of two, so 0.1 cannot be written exactly that way. The nearest double is 3602879701896397 / 36028797018963968, which is about 0.1000000000000000055511151231257827. That tiny excess is why 0.1 + 0.2 famously prints as 0.30000000000000004.
What is the “exact fraction” versus the “simplest fraction”?
The exact fraction is the precise rational the double holds — its denominator is always a power of two, so it can be huge. The simplest fraction is the rational with the smallest denominator that still rounds to that same double; for 0.1 that is just 1/10. It is the value you most likely intended before binary rounding got in the way.
How is the simplest fraction found?
By a continued-fraction (Stern–Brocot) best-approximation search. The tool walks the convergents and semiconvergents of the stored value, keeping the fraction with the smallest denominator whose nearest double is identical to the input. This is the classic “shortest round-tripping” rational.
When can a fraction NOT be stored exactly?
A double can store a/b exactly only when the reduced denominator b is a power of two (1, 2, 4, 8, 16, …) and the value fits in 53 bits of precision. So 3/4 is exact, but 1/3, 1/10 and 1/7 are not — the tool flags these and shows the nearest stored value instead.
Is this exact, or just to a few decimal places?
Exact. All arithmetic uses JavaScript BigInt with no rounding, so the numerator, denominator and full decimal expansion are mathematically precise — not truncated. Everything runs in your browser; nothing is uploaded.
How do I use the Float → Exact Fraction — What an IEEE-754 Double Really Stores?
Simply type or paste your value and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Is it free? Does it work without internet?
Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.
Where does my data go?
Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.
Common Use Cases
Debugging floating-point bugs
See exactly why a sum, comparison or rounding came out “wrong” by reading the true rational a double stores, down to the last digit.
Teaching IEEE-754
Show students that 0.1 is really 3602879701896397/36028797018963968, and that 0.5 or 0.25 are exact while 0.3 is not.
Choosing safe constants
Check whether a literal you plan to hard-code (a price, a ratio, a step size) lands on an exact double or carries hidden error.
Recovering intended values
Given a messy float dumped from a log, get back the clean fraction a human probably typed using best-rational approximation.
Last updated: