How to use the Double to Hex Converter tool
- Type a decimal value in Number, for example -13.25, 6.02214076e23 or Infinity.
- Select Convert. Selecting Example fills in -13.25 and converts it.
- Read the result, which is 0x followed by 16 uppercase hex digits with the sign bit first.
- Select Copy to paste the pattern into code, a test fixture or a hex editor.
How a double becomes 16 hex digits
IEEE 754 binary64 stores a number in three fields: 1 sign bit, 11 exponent bits with a bias of 1023, and 52 fraction bits. Sign and exponent together are 12 bits, which is exactly three hex digits, and the fraction fills the other thirteen. That alignment makes a double's hex form readable by eye.
Take 0xC02A800000000000. The first three digits, C02, are 1100 0000 0010 in binary: sign 1, exponent field 402 hex, or 1026. Subtracting 1023 gives 3. The fraction digits A8 are 1010 1000, so the significand is 1.10101 in binary, or 1.65625. The value is -1.65625 x 2^3 = -13.25.
Double to hex reference conversions
These outputs come straight from the tool. Notice 0.1: the repeating 9s and the final A show that one tenth has no finite binary expansion and was rounded up in the last bit.
-13.25 -> 0xC02A800000000000
1 -> 0x3FF0000000000000
0.1 -> 0x3FB999999999999A
3.141592653589793 -> 0x400921FB54442D18
-0 -> 0x8000000000000000
Infinity -> 0x7FF0000000000000
NaN -> 0x7FF8000000000000Accepted number formats and edge cases
The Number field takes decimal notation only. Input that does not match gets the message Enter a number, Infinity or NaN.
- Digits with an optional leading + or -, an optional decimal point, and an optional exponent such as e23 or E-7. Forms like .5 and 5. are fine.
- inf, infinity and nan in any letter case. A sign on nan is ignored, and the result is the quiet NaN 0x7FF8000000000000.
- Hex literals, underscores, thousands separators and fractions such as 1/3 are rejected.
- Magnitudes above the largest double overflow: 1e309 gives 0x7FF0000000000000.
- 5e-324 is the smallest subnormal, 0x0000000000000001. 1e-324 is closer to zero and gives all zeros.
- Integers above 2^53 round to the nearest representable value: 9007199254740993 becomes 0x4340000000000000, which is 9007199254740992.
Byte order when comparing with memory
The output is the 64-bit pattern read as one number, most significant byte first. On little-endian machines, which covers x86-64 and nearly all Arm systems, memory holds the bytes in reverse: -13.25 appears in a dump as 00 00 00 00 00 80 2A C0. Big-endian wire formats, such as the one written by Java's DataOutputStream.writeDouble, match the tool's order directly.
Frequently asked questions
How do I convert a double to hex in code?
In Python, struct.pack('>d', x).hex() returns the same 16 digits. In C, copy the double into a uint64_t with memcpy and print it with a 16-digit hex format. In JavaScript, write it with DataView.setFloat64 and read it back with getBigUint64.
Why is 0.1 stored as 0x3FB999999999999A?
In binary, 0.1 is the repeating fraction 0.000110011 and so on. The double keeps 53 significant bits and rounds the rest, which produces the run of 9s and a final A. The stored value is slightly above one tenth.
Is this the same as the C hex float format %a?
No. The %a format prints a readable significand and exponent, such as 0x1.999999999999ap-4 for 0.1. This tool prints the raw bit pattern, 0x3FB999999999999A, which is what you see in memory, files and network packets.
What is the hex value of the largest double?
The largest finite double, 1.7976931348623157e308, is 0x7FEFFFFFFFFFFFFF: exponent field 7FE with every fraction bit set. One step higher in the exponent, 7FF, is reserved for Infinity and NaN.
How is this different from Float to Hex?
Float to Hex rounds the number to 32-bit single precision and prints 8 digits. This page keeps the 64-bit value and prints 16. -13.25 is 0xC1540000 as a float and 0xC02A800000000000 as a double.