Free tool · Developer tools
Float to hex converter
Type a decimal number into this float to hex converter and pick 32 or 64 bits. 0.1 in 32 bits is 0x3DCCCCCD, and in 64 bits it is 0x3FB999999999999A. The page splits the bits into sign, exponent and fraction, shows the exact value the pattern stores, and reads a hex pattern back into a number.
- Free
- No sign-up
- Runs in your browser
0x3DCCCCCD0.1 as 32-bit float
- normal
- sign plus
- Stored as the nearest 32-bit value, which is not exactly 0.1.
- Sign, exponent, fraction bits
- 0 01111011 10011001100110011001101
- Exponent field
- 123 (power of two -4)
- Fraction field
- 0x4CCCCD
- Kind
- normal
- Exact stored value
- 0.100000001490116119384765625
| Format | Hex pattern |
|---|---|
| 32-bit | 0x3DCCCCCD |
| 64-bit | 0x3FB999999999999A |
How to use the Float to Hex (IEEE 754) Converter
- Choose Decimal number to hex or Hex to decimal number under Direction.
- Pick the Format: 32-bit float (single) or 64-bit float (double).
- Type the Value: a number such as 0.1 or 1e-10, or the hex digits of a pattern.
- Read the hex, the bit fields and the exact stored value, then press Copy the result.
How do you convert a float to hex?
A float is stored as three bit fields: one sign bit, an exponent field and a fraction field. The 32-bit format uses 1, 8 and 23 bits and the 64-bit format uses 1, 11 and 52 bits. To convert 0.1, write it as a binary fraction times a power of two: 0.1 is about 1.6 × 2^-4. The exponent field stores the power plus a bias of 127, so -4 becomes 123. The fraction field keeps the digits after the leading 1, rounded to 23 bits.
Joined together, the 32 bits are 0 01111011 10011001100110011001101. Read in groups of four from the left, that is 0x3DCCCCCD. The 64-bit pattern for the same number is 0x3FB999999999999A, with a bias of 1023 and 52 fraction bits. The converter does this for any number you type and prints the same split under the answer.
What are the hex patterns for common numbers?
Powers of two and short binary fractions have clean patterns, because their fraction field holds only a few ones. Numbers such as 0.1 and 3.14159 have no finite binary form, so their fraction fields run on and are cut off by rounding.
| Number | 32-bit hex | 64-bit hex |
|---|---|---|
| 1 | 0x3F800000 | 0x3FF0000000000000 |
| -2.5 | 0xC0200000 | 0xC004000000000000 |
| 6 | 0x40C00000 | 0x4018000000000000 |
| 0.15625 | 0x3E200000 | 0x3FC4000000000000 |
| 0.1 | 0x3DCCCCCD | 0x3FB999999999999A |
| 3.14159 | 0x40490FD0 | 0x400921F9F01B866E |
Why is 0.1 not stored exactly?
Only sums of powers of two can be stored without error, and 0.1 is not one of them. The 32-bit pattern 0x3DCCCCCD holds exactly 0.100000001490116119384765625, and the 64-bit pattern holds 0.1000000000000000055511151231257827021181583404541015625. Both are the nearest value the format has, which is why the result panel says when a number is stored as its nearest neighbor. The 32-bit pattern is rounded once, straight from the digits you type, so a long decimal sitting just above a halfway point lands on the upper neighbor instead of being rounded twice.
The same limit shows up with whole numbers. A 32-bit float has 24 significant bits, so 16,777,217 rounds to 16,777,216 and gets the pattern 0x4B800000. A 64-bit float has 53 significant bits, which is why whole numbers stay exact up to about 9 quadrillion.
To go the other way, type a pattern with the direction set to hex. The pattern 0x40490FDB reads as 3.1415927410125732, which is pi rounded to 32 bits, and its exact value is 3.1415927410125732421875. Patterns may start with 0x and may contain spaces, and shorter patterns are padded with zeros on the left.
What do zero, infinity, NaN and subnormal numbers look like?
An exponent field of all zeros means zero when the fraction is also zero, and a subnormal number otherwise. An exponent field of all ones means infinity when the fraction is zero, and NaN otherwise. The smallest 32-bit subnormal is the pattern 0x00000001 and the smallest positive value, about 1.4 × 10^-45.
Numbers too large for the format round to infinity, and numbers too small round to zero, and the page tells you when that happens. For whole numbers in other bases or for text as hex bytes, try the number base converter or the ASCII to hex converter. Sums in base 2 are in the binary calculator.
| Value | 32-bit hex | 64-bit hex |
|---|---|---|
| Zero | 0x00000000 | 0x0000000000000000 |
| Negative zero | 0x80000000 | 0x8000000000000000 |
| Infinity | 0x7F800000 | 0x7FF0000000000000 |
| Negative infinity | 0xFF800000 | 0xFFF0000000000000 |
| NaN (the usual quiet one) | 0x7FC00000 | 0x7FF8000000000000 |
Use it with
- ASCII to Hex Converter: convert ASCII text to hex codes with a byte table, control character names and five output styles. Accents and emoji become UTF-8 bytes.
- Binary Calculator: binary calculator for adding, subtracting, multiplying and dividing binary numbers of any length, with carries shown, decimal and hex answers.
- Number Base Converter: binary, octal, decimal, hex.
Questions
What is 0.1 as an IEEE 754 float in hex?
In 32 bits it is 0x3DCCCCCD, and in 64 bits it is 0x3FB999999999999A. Neither is exactly one tenth.
How many bits are in the exponent and fraction?
The 32-bit format has 8 exponent bits and 23 fraction bits. The 64-bit format has 11 exponent bits and 52 fraction bits. Both add one sign bit.
What is the exponent bias?
It is 127 for 32-bit floats and 1023 for 64-bit floats. The real exponent is the stored field minus the bias, so a stored 127 means a power of two of 0.
How do I convert hex back to a float?
Set the direction to hex, pick the format and type the digits. For example 40490FDB in 32 bits reads as 3.1415927410125732.
Why does the result say "nearest 32-bit value"?
The typed number has no exact form in that format, so the nearest representable number is stored. The exact stored value is printed in the facts list.
Does the number I type leave the page?
No. The conversion runs on the page with the browser's own number handling, and nothing is sent anywhere.
Sources
The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.