IEEE 754 Double Precision Converter (64-Bit)
Convert decimals to IEEE 754 double precision (binary64) and back: all 64 bits, the exact value a double really holds, and the rounding error down to the last digit.
Decimal input accepts -1.5e-3, fractions like 1/3, C hex floats like 0x1.8p3, pi, inf and nan. Conversion is exact: no intermediate rounding through a double.
Bits (click to flip)
sign · exponent · fraction · bit 63 on the left
| Value stored (exact) | 0.1000000000000000055511151231257827021181583404541015625 |
|---|---|
| Shortest round-trip decimal | 0.1 |
| Rounding error (stored − input) | 0.0000000000000000055511151231257827021181583404541015625 ≈ 5.55112e-18, relative 5.551e-17 |
| Hexadecimal | 0x3FB999999999999A |
| Binary | 0 01111111011 1001100110011001100110011001100110011001100110011010 |
| Sign | 0 (positive) |
| Exponent | field 01111111011 = 1019; bias 1023; actual exponent -4 |
| Fraction (mantissa) | 1001100110011001100110011001100110011001100110011010 = 2702159776422298 / 252 (hidden leading 1 added) |
| Formula | (+1) × 1.600000000000000088817841970012523233890533447265625 × 21019 − 1023 = (+1) × 1.600000000000000088817841970012523233890533447265625 × 2-4 |
| Category | Normal number |
| Gap to next value (ULP) | 2-56 ≈ 1.38778e-17 |
| Next value up / down | 0.10000000000000002 (0x3FB999999999999B) 0.09999999999999999 (0x3FB9999999999999) |
Decimal → IEEE 754, step by step
- Sign. The number is positive, so the sign bit is 0.
- Convert |x| to binary. 0.1 = 0.000112 (the overlined block repeats forever).
- Normalize. Move the binary point so one 1 is left of it: |x| = 1.… × 2-4.
- Exponent. Add the bias: -4 + 1023 = 1019 = 011111110112.
- Fraction. Keep the 52 bits after the leading 1. The bits beyond them are not all zero, so the value is rounded to the nearest representable number (ties go to the even one). Fraction = 1001100110011001100110011001100110011001100110011010.
- Assemble sign | exponent | fraction: 0 01111111011 1001100110011001100110011001100110011001100110011010 = 0x3FB999999999999A.
Double-precision layout
- Sign: bit 63.
- Exponent: bits 62–52 (11 bits), bias 1023; normal exponents from −1022 to +1023.
- Fraction: bits 51–0 (52 bits) plus the hidden 1: 53 significant bits.
- Value of a normal double: (−1)s × 1.f × 2e − 1023.
What a double really stores
| You type | Hex | Exact stored value |
|---|---|---|
| 0.1 | 0x3FB999999999999A | 0.1000000000000000055511151231257827021181583404541015625 |
| 0.2 | 0x3FC999999999999A | 0.200000000000000011102230246251565404236316680908203125 |
| 0.3 | 0x3FD3333333333333 | 0.299999999999999988897769753748434595763683319091796875 |
| 0.30000000000000004 | 0x3FD3333333333334 | 0.3000000000000000444089209850062616169452667236328125 |
| 1 | 0x3FF0000000000000 | 1 |
| 9007199254740993 | 0x4340000000000000 | 9007199254740992 |
| 1e308 | 0x7FE1CCF385EBC8A0 | 100000000000000001097906362944045541740492309677311846336810…430223118336 |
| 5e-324 | 0x0000000000000001 | 0.0000000000000000000000000000000000000000000000000000000000…533447265625 |
Every finite double has a finite decimal expansion (a binary fraction with k bits after the point has exactly k decimal digits after the point), so the converter can print it in full. The shortest string that converts back to the same bits is what languages print by default: that is why the stored value of 0.1 still prints as “0.1”.
Worked example: 0.1 to double
- 0.1 = 0.0001100110011…2, with 0011 repeating forever.
- Normalize: 1.100110011…2 × 2−4. Exponent field: −4 + 1023 = 1019 =
01111111011. - The fraction is 1001 repeated, cut at 52 bits: the bits that follow (1001…) are more than half an ULP, so the last bit rounds up, giving
…1010at the end. - Result:
0x3FB999999999999A= 0.1000000000000000055511151231257827021181583404541015625.
Frequently asked questions
What is IEEE 754 double precision?
Double precision (binary64) is the 64-bit IEEE 754 format: 1 sign bit, 11 exponent bits with a bias of 1023, and 52 fraction bits. With the hidden bit it carries 53 significant bits, about 15–17 decimal digits. It is the type of double in C, C++, Java and C#, float in Python, and every Number in JavaScript.
Why does 0.1 + 0.2 not equal 0.3?
Neither 0.1 nor 0.2 is exact in binary. Their stored values are slightly above the decimal ones, and the rounded sum is 0x3FD3333333333334, which prints as 0.30000000000000004. The double closest to 0.3 is 0x3FD3333333333333, one ULP lower. The two differ by 2−54 ≈ 5.55 × 10−17.
What is the largest integer a double can store exactly?
Every integer up to 253 = 9,007,199,254,740,992 is exact. Beyond that the spacing between doubles is 2 or more, so 253 + 1 = 9,007,199,254,740,993 rounds to 9,007,199,254,740,992. JavaScript calls 253 − 1 Number.MAX_SAFE_INTEGER.
What are the limits of double precision?
The largest finite double is about 1.7976931348623157 × 10308, the smallest normal 2.2250738585072014 × 10−308, and the smallest subnormal 2−1074 ≈ 4.94 × 10−324. Machine epsilon is 2−52 ≈ 2.22 × 10−16.
Sources
- IEEE Std 754-2019, IEEE Standard for Floating-Point Arithmetic, IEEE, 2019 (revision of IEEE 754-2008 and IEEE 754-1985).
Related tools and guides
- IEEE 754 converter IEEE 754 converter for single, double, half precision and bfloat16: decimal ↔ hex ↔ binary, clickable bits, the exact stored value and the rounding error.
- 16-bit half precision Convert numbers to and from IEEE 754 half precision (16-bit, binary16): 1 sign bit, 5 exponent bits, 10 fraction bits. Range, precision and worked examples.
- Base converter Convert numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, including fractions with repeating digits, with steps.
- Two's complement Convert between decimal and two's complement binary or hex for any width up to 256 bits. Steps, ranges, one's complement, sign-magnitude and overflow flags.