Decimal to IEEE 754 double precision (float64)

This is the number type used by JavaScript, Python and Excel, so here you can see why 0.1 + 0.2 is not exactly 0.3.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter decimal number.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Value = (-1)^S × 1.F × 2^(E - 1023), with a sign bit S, an 11-bit exponent E and a 52-bit fraction F. Rounded to the nearest representable value, ties to even.

Example

Inputs: Decimal number = 0.1. Result: Hex encoding: 0x3FB999999999999A; Value class: Normal.

0.1
0x3FB999999999999A

Limits and caveats

  • Infinity, -Infinity and NaN are accepted; NaN uses the standard quiet pattern 0x7FF8000000000000.
  • For very small numbers the stored value can run to hundreds of digits because it is written in full.

Questions about this tool

What is 0.1 as a double?

0x3FB999999999999A, storing 0.1000000000000000055511151231257827021181583404541015625.

Why is 0.1 + 0.2 not equal to 0.3?

All three are stored approximately, and the sum of the stored 0.1 and 0.2 lands on a different double from the stored 0.3.

What is the largest integer a double holds exactly?

2⁵³ = 9007199254740992. Beyond it not every integer fits, so 9007199254740993 becomes 9007199254740992.