Time/Numbers
IEEE 754 Float Converter
Decimal number ↔ IEEE 754 binary representation (single or double precision) — sign, exponent, mantissa, special values.
Computers store fractional numbers in binary under the IEEE 754 standard — a sign, an exponent, and a mantissa, packed into a fixed number of bits. This tool shows that representation for any decimal number and parses it back into a number.
How to use it
- Number → bits: enter a decimal number to get its breakdown into sign, exponent, and mantissa for single (32-bit) or double (64-bit) precision.
- Bits → number: paste a bit representation to get the decimal value back.
- Special values (infinity, NaN, signed zero) are recognized and explained separately.
Common uses
- Understanding why 0.1 + 0.2 doesn't exactly equal 0.3 in most programming languages — a concrete demonstration of rounding error.
- Studying float's internal representation to understand precision limits in financial or scientific calculations.
- Parsing a binary dump or network packet where numbers are transmitted in IEEE 754 format.
Things to keep in mind
Most decimal fractions (0.1, for example) have no exact binary representation — that's the root cause of the typical rounding errors seen in calculation results.
Comparing floating-point numbers for exact equality (===) is unreliable — check instead whether the difference is smaller than a small threshold (epsilon).
Article about this tool: IEEE 754: why 0.1 + 0.2 doesn't equal 0.3 in code
Frequently asked questions
What's the difference between single and double precision?
Single precision (float, 32 bits) gives about 7 decimal digits of precision, double precision (double, 64 bits) gives about 15-17. JavaScript's Number type uses double precision.
Why do some decimal numbers lose precision?
IEEE 754 stores numbers in binary, and many decimal fractions (like 0.1) have no exact finite binary representation — so the closest possible value is stored, with a tiny rounding error.
What do NaN, Infinity, and -0 mean?
NaN is the result of an invalid operation like 0/0. Infinity/-Infinity appear when a value overflows the representable range (e.g. dividing by 0). +0 and -0 are two different bit representations of signed zero, which are nonetheless equal as numbers.
What are subnormal (denormalized) numbers?
A special representation mode for numbers too small in magnitude for the normal format — the mantissa's implicit leading 1 is dropped, allowing a gradual approach toward zero instead of a sudden jump, at the cost of some precision.
How should I properly compare floating-point numbers instead of checking exact equality?
Instead of a === b, check whether the difference between the numbers is smaller than a small threshold (epsilon): Math.abs(a - b) < 1e-9. Exact equality is almost never guaranteed due to rounding errors.