What is 0.1 in IEEE 754 single precision?
0x3DCCCCCD. The stored value is 0.100000001490116119384765625, because 0.1 has no finite binary form. As a double it is 0x3FB999999999999A.
The IEEE 754 floating-point converter below shows the sign, exponent and fraction bits of a float32 or float64, converts decimal to hex and hex to decimal, and reads out the exact value that is stored. Click any bit to flip it.
Click any bit to flip it. Bit 31 is on the left.
SignExponentFraction
binary32 bit pattern
0x3DCCCCCD
Normal, reads back as 0.1
The input needs more significant bits than binary32 has, so it was rounded to the nearest float (ties to the even significand, the IEEE default).
Exact value stored, every digit
0.100000001490116119384765625
Write the number as ±1.f × 2e, then store the sign, e plus the bias (127 for float32, 1023 for float64), and the bits of f rounded to the nearest float. 0.1 is 1.6 × 2−4, so as a float32 the exponent field is 123 and the pattern is 0x3DCCCCCD, which holds 0.100000001490116119384765625.
A floating-point number is a binary version of scientific notation, split into three fields: one sign bit, an exponent field and a fraction field.
Two exponent field values are reserved. All zeros means zero or a subnormal value, with no implicit leading 1:
All ones means infinity when the fraction is zero and NaN otherwise. A decimal input rarely has an exact binary form, so it is rounded to the nearest float, with exact ties going to the float whose last significand bit is 0. This floating-point calculator does that on exact integer arithmetic, so a decimal never takes a detour through a double on its way to a float32, which would round twice.
0.1 = 1.6 × 2⁻⁴, so e = -4 and the exponent field is -4 + 127 = 123. The fraction 0.6 × 2²³ = 5033164.8 rounds to 5033165, or 0x4CCCCD. Together the fields give 0x3DCCCCCD. The value stored is 0.100000001490116119384765625, an error of 1.49e-9 or 0.2 ULP.
In binary the top bit is 1, so the value is negative. The next 8 bits are 128, giving e = 1. The significand is 1.57079637050628662109375, so the value is −1.57079637050628662109375 × 2 = -3.1415927 (exactly -3.1415927410125732421875). This is −π as a float32.
16,777,217 is 2²⁴ + 1 and needs 25 significant bits, one more than a float32 has. It is an exact tie between two floats, so it rounds to the one with the even significand: 16777216 (0x4B800000). A float64 hits the same wall at 2⁵³ + 1, where 9,007,199,254,740,993 becomes 9007199254740992. A counter held in a float32 eventually stops increasing.
The limits every float.h is built from, computed from the bit patterns themselves.
| Parameter | float32 (binary32) | float64 (binary64) |
|---|---|---|
| Total bits | 32 | 64 |
| Exponent bits | 8 | 11 |
| Fraction bits | 23 | 52 |
| Precision p | 24 bits | 53 bits |
| Exponent bias | 127 | 1023 |
| Normal exponent range | -126 to +127 | -1022 to +1023 |
| Largest finite | 3.4028235e+38 | 1.7976931348623157e+308 |
| Smallest normal | 1.1754944e-38 | 2.2250738585072014e-308 |
| Largest subnormal | 1.1754942e-38 | 2.225073858507201e-308 |
| Smallest subnormal | 1e-45 | 5e-324 |
| Machine epsilon | 1.1920929e-7 | 2.2204460492503131e-16 |
| Unit roundoff | 5.96046448e-8 | 1.1102230246251565e-16 |
| Decimal digits kept | 6 | 15 |
| Digits to round-trip | 9 | 17 |
| All integers up to | 16,777,216 | 9,007,199,254,740,992 |
| C type | float | double |
Decimal inputs are rounded to the nearest float. π is entered to 20 decimal places.
| Value | float32 hex | float64 hex |
|---|---|---|
| +0 | 0x00000000 | 0x0000000000000000 |
| −0 | 0x80000000 | 0x8000000000000000 |
| 1 | 0x3F800000 | 0x3FF0000000000000 |
| −1 | 0xBF800000 | 0xBFF0000000000000 |
| 0.5 | 0x3F000000 | 0x3FE0000000000000 |
| 2 | 0x40000000 | 0x4000000000000000 |
| 0.1 | 0x3DCCCCCD | 0x3FB999999999999A |
| 0.2 | 0x3E4CCCCD | 0x3FC999999999999A |
| 0.3 | 0x3E99999A | 0x3FD3333333333333 |
| 10 | 0x41200000 | 0x4024000000000000 |
| 100 | 0x42C80000 | 0x4059000000000000 |
| π | 0x40490FDB | 0x400921FB54442D18 |
| +∞ | 0x7F800000 | 0x7FF0000000000000 |
| −∞ | 0xFF800000 | 0xFFF0000000000000 |
| Quiet NaN | 0x7FC00000 | 0x7FF8000000000000 |
This IEEE 754 calculator covers binary32 and binary64 with the default rounding mode. The quiet and signaling labels follow the IEEE 754-2008 convention for the top fraction bit, which some older MIPS processors reverse.
0x3DCCCCCD. The stored value is 0.100000001490116119384765625, because 0.1 has no finite binary form. As a double it is 0x3FB999999999999A.
Round the number to the nearest float, then read the sign, exponent and fraction fields together as one hex pattern. 0.1 is 0x3DCCCCCD as a float32 and 0x3FB999999999999A as a float64. This IEEE 754 converter does the rounding on exact integer arithmetic.
Split the pattern into its sign, exponent and fraction fields, then, unless the exponent field is all zeros or all ones, apply value = (−1)ˢ × 1.f × 2^(E − bias). 0xC0490FDB has the sign bit set and an exponent field of 128, which makes it -3.1415927. The hex to float converter above takes any pattern, including little-endian memory dumps.
None of the three has an exact binary form, so each is stored rounded: as doubles, 0.1 is 0x3FB999999999999A, 0.2 is 0x3FC999999999999A and 0.3 is 0x3FD3333333333333. The rounding errors of 0.1 and 0.2 do not cancel, so their sum lands on the neighboring double, 0.30000000000000004.
A float32 reliably keeps 6 decimal digits and a float64 keeps 15. To print a value so that it reads back to the same bits, use 9 significant digits for float32 and 17 for float64.
The gap between 1 and the next larger float: 2^−23 (1.19209e-7) for float32 and 2^−52 (2.22045e-16) for float64. The maximum relative rounding error, or unit roundoff, is half of that.
Values smaller than the smallest normal float (1.1754944e-38 for float32), stored with an exponent field of zero and no implicit leading 1. They let values fade gradually to zero at the cost of precision.
Both have every exponent bit set. A fraction of zero means infinity, and the sign bit picks + or −. Any nonzero fraction is NaN, with the top fraction bit set for a quiet NaN and clear for a signaling NaN.
Every integer up to 2^24 (16,777,216) fits a float32, and every integer up to 2^53 (9,007,199,254,740,992) fits a float64. Above that some integers are skipped, although every float that large is still a whole number.
The significand is the full 1.xxx number including the implicit bit. The fraction (the IEEE standard calls it the trailing significand) is the part actually stored. Mantissa is the older informal word for either.
See all free electronics tools →
ProtoFlow is free AI PCB design software: describe a circuit and get a schematic with real parts, PCB layout with an autorouter, SPICE simulation and Gerber files. Native KiCad, Altium and EAGLE import and export. Free on macOS, Windows and Linux.
Free to start. No card required.