Skip to content
gohacks.dev
Tooling

IEEE 754 Float Inspector

See how a number is stored as a 64-bit double or 32-bit float: sign, exponent and mantissa bits, hex, the exact decimal value stored and the gap to the next value.

Free · No sign-up · Your inputs stay in your browser

Input

Inspect IEEE 754 floating-point numbers

Output

Stored as 0.10000000000000000555111512312578270211...

0 01111111011 1001100110011001100110011001100110011001100110011010
Signpositive
Exponent-4
Mantissa bits52
Hex0x3fb999999999999a
Exact stored value0.1000000000000000055511151231257827021181583404541015625
Shortest round-trip0.1
Gap to next value (ULP)1.388e-17

Most decimal fractions have no exact binary form, so 0.1 is stored as the nearest double, which is slightly more than 0.1; adding two such errors gives 0.30000000000000004. The exact decimal value of the stored bits is shown in full. Doubles hold every integer up to 2^53 exactly and nothing beyond; money belongs in integers of cents or a DECIMAL column, never in a float.

Runs in this browser. Nothing you paste is sent to a server.

Why 0.1 + 0.2 is not 0.3

0.1 has no finite binary representation, so the stored double is the nearest one, which is slightly more than 0.1, and 0.2 is likewise slightly off. Their sum lands on a different double from the one nearest 0.3, printed as 0.30000000000000004. The format is defined by IEEE 754; the classic explanation is Goldberg's What Every Computer Scientist Should Know About Floating-Point Arithmetic.

Practical consequences

Never compare floats for exact equality; compare with a tolerance. Doubles hold every integer up to 2^53 exactly and no further, which is why large ids must travel as strings in JSON. Money belongs in integer cents or a decimal type.

Share

Frequently asked questions

What is the largest integer a double can represent exactly?
2^53, 9,007,199,254,740,992, which JavaScript exposes as Number.MAX_SAFE_INTEGER + 1. Beyond it, not every integer can be stored.
What is the difference between float and double?
float is 32 bits with about 7 significant decimal digits; double is 64 bits with about 15 to 17. Use double unless memory is tight.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools