Hex to Float
Paste IEEE 754 hex, one value per line, with or without 0x. Get the float or double as a short decimal, and its exact value in Bits. Nothing leaves your browser.
Also: All formats, Float to Hex, Float to Bin
- 0
- Numbers
- 0
- Rounded
- 0
- Errors
On this page
About Hex to Float
Updated
Hex to Float reads the hex bits of an IEEE 754 float and gives the number. Use it for a memory dump, a debugger window, a Modbus register, a network capture or a binary file. Paste one value or a whole column.
It reads hex as it comes: with or without 0x, in capitals or not, with spaces between bytes, and low byte first if you set Byte order to Little-endian. The answer is the shortest decimal that gives the same bits. Bits shows every exact digit of the stored value.
The same tool, set up for other jobs: IEEE 754 Converter, Float to Hex, Float to Binary. For whole numbers in any base, use the Number Base Converter.
How to use it
- Paste hex values, one per line, or load a file. Tabs, semicolons and a comma with a space after it also split a line.
- Pick the Format: 16-bit half, bfloat16, 32-bit single, 64-bit double or 128-bit quad. It is in the Result header. On a phone it is under More.
- Check From and To, next to Convert. On a phone they are under More.
- Press Convert (Alt C). Results shows each value and its hex. Output has only the answers, for Copy and Download.
- Open Bits to see the sign, exponent and mantissa of one number. Click a bit to flip it, or step to the next float up or down. Steps shows the work by hand.
- Swap (Alt S) puts the answers in the editor and turns From and To around, so you can check the way back.
How to convert hex to float by hand
Hex C2 C8 00 00
Binary 1100 0010 1100 1000 0000 0000 0000 0000
Split 1 | 10000101 | 10010000000000000000000
Sign 1 negative
Exponent 10000101 = 133 - 127 = 6
Mantissa 1.1001 (binary) = 1.5625
Value -1.5625 x 2^6 = -100Special values
An exponent of all ones means Infinity (mantissa zero) or NaN (anything else). All zeros means zero or a subnormal.
7F800000 Infinity
FF800000 -Infinity
7FC00000 NaN, quiet
7F800001 NaN, signaling, payload 0x1
80000000 -0
00000001 1e-45, the smallest subnormal
7F7FFFFF 3.4028235e+38, the largest floatCommon errors
A letter that is not hex
Hex bits use 0 to 9 and A to F. A capital O for a zero is the most common slip when a value is typed from a screen. The tool marks the letter. Other converters show only "ERROR" or a blank field.
4O490FDB
"O" is not a hex digit. Hex digits are 0 to 9 and A to F. Is it a zero?40490FDBToo many digits for the format
A 32-bit float has 8 hex digits and a 64-bit double has 16. Sixteen digits in 32-bit mode is a double, and the tool says which format to pick.
3FF0000000000000
16 hex digits is a 64-bit (double) float. Set Format to 64-bit.3FF0000000000000 (Format: 64-bit) = 1The wrong byte order
A hex editor on x86 or ARM shows the low byte first: 1.0 is 00 00 80 3F. Read as big-endian, that is a tiny subnormal number. If the answers look like nonsense, set Byte order to Little-endian.
Hex to float in code
C uint32_t u = 0x41C80000; float f; memcpy(&f, &u, sizeof f);
Python struct.unpack(">f", bytes.fromhex("41c80000"))[0] # 25.0
float.fromhex("0x1.9p+4") # 25.0
JavaScript const dv = new DataView(new ArrayBuffer(4));
dv.setUint32(0, 0x41c80000); dv.getFloat32(0) // 25
Java Float.intBitsToFloat(0x41C80000)Hex to float resources
- Single-precision floating-point formatThe 32-bit float bit by bit, with worked examples and the exact limits.
- Double-precision floating-point formatThe 64-bit double that JavaScript, Python and most languages use for every number.
- Endianness on WikipediaBig-endian and little-endian byte order, and which CPUs and file formats use each.
- Python: structstruct.pack('>f', 0.1).hex() gives the 32-bit bits; '<f' gives them little-endian.
- Python: float.hex() and float.fromhex()The C hex float form in Python: (0.1).hex() is '0x1.999999999999ap-4'.
- MDN: DataViewsetFloat32 and getUint32 read the bits of a float in JavaScript, in either byte order.
Hex to float FAQ
How do I convert hex to float?
Write the hex as bits and split them: for 32-bit, 1 sign bit, 8 exponent bits and 23 mantissa bits. Take 127 off the exponent, put a 1 in front of the mantissa, and multiply.
For 41C80000: the bits are 0 10000011 10010000000000000000000. The exponent is 131 − 127 = 4, the mantissa is 1.5625, and 1.5625 × 2^4 = 25. Open Steps to see it done for your value.
What float is 0x3F800000?
3F800000 is 1.0 as a 32-bit float. 40000000 is 2.0, BF800000 is -1.0 and 3F000000 is 0.5.
How do I convert hex to double?
Set Format to 64-bit and paste 16 hex digits. 3FB999999999999A is 0.1 and 400921FB54442D18 is π. If you paste 16 digits in 32-bit mode, the tool says which format to pick.
Why does my hex give a strange tiny number?
The bytes are most likely little-endian. A hex editor on x86 or ARM shows 1.0 as 00 00 80 3F; read the other way, that is 4.6e-41. Set Byte order to Little-endian.
How do I read a float from two Modbus registers?
A 32-bit float spans two 16-bit registers. Paste them together, such as 41C8 0000 for 25.0. Some devices send the low register first (word swap): if the result looks wrong, swap the two groups and try again.
How do I convert hex to float in Python or C?
Python: struct. gives 25.0; use '<f' for little-endian and '>d' for a double. C: copy a uint32_t into a float with memcpy.
Are my numbers sent anywhere?
No. Every number is converted in your browser, with exact BigInt math. Nothing is uploaded, and there are no ads or cookie walls. You can check this in your browser's network tab while you use it.