Introduction
IEEE 754 binary floating-point encodes real numbers with a sign bit, a biased exponent field and a fractional significand. It is the representation GATE means by "floating point" under Digital Logic, and the one C float/double use on essentially all hosts. This note covers binary32 and binary64 layouts, normal and subnormal values, special encodings (zeros, infinities, NaNs), and range/precision. Arithmetic steps continue in Floating-Point Arithmetic.
GATE asks you to encode a decimal value into hex, decode a hex pattern, classify special patterns, compute the range and precision of the standard formats or of a small custom format given in the stem, and reason about gaps between neighbouring values.
The Programming and Data Structures notes on C floating types refer to this note for the bit-level meaning.
Prerequisites
- Number Systems and Base Conversion: binary fractions.
- Signed Number Representation: sign bit concept (IEEE uses sign-magnitude style for the significand, not two's complement).
Core concepts
Binary32 and binary64 layouts
Bits are written MSB first (sign on the left).
| Format | Total bits | Sign | Exponent bits | Fraction bits | Exponent bias |
|---|---|---|---|---|---|
| binary32 (single) | 32 | 1 | 8 | 23 | 127 |
| binary64 (double) | 64 | 1 | 11 | 52 | 1023 |
Value of a normal finite number with sign , stored exponent field , and fraction field (interpreted as the bits after the binary point of the significand):
The leading 1 before the point is the hidden bit (implicit bit); it is not stored for normals. For a -bit exponent field the bias is : 127 for 8 bits, 1023 for 11, 15 for the 5-bit field of binary16.
Exponent field regimes (binary32)
| Stored | Meaning |
|---|---|
| zeros if ; subnormals if | |
| normals; true exponent | |
| / if ; NaN if |
binary64 is analogous with and as the special endpoints and bias 1023; normal exponents run .
Subnormals
When and ,
(so binary32 multiplies by ). Subnormals fill the gap near zero and allow gradual underflow. The hidden bit is 0.
The gap at zero. Without subnormals, the smallest positive value would be , yet the next value above it is only further on. The hole between 0 and would be times wider than the spacing just above it. Subnormals fill that hole with values spaced apart, the same spacing as in the lowest normal binade, so only when .
Zeros, infinities, NaNs
- : all bits zero. : sign 1, other bits zero. They compare equal as floating values but are bit-distinct; and .
- : all ones, .
- NaN: all ones, . Quiet NaNs have the fraction MSB set; signaling NaNs have it clear with some other fraction bit set. NaN compares unequal to everything, including itself. Operations such as , and produce NaN.
- Counting patterns (binary32). Exponent 255 takes patterns: 2 infinities and NaNs. The other patterns are finite numbers, including the two zeros.
Precision and range (binary32)
- Precision: 24 significant bits counting the hidden 1 (23 stored + 1), about decimal digits.
- Max finite: .
- Min positive normal: .
- Min positive subnormal: .
- Machine epsilon (gap from 1.0 to the next value): .
- Every integer with magnitude up to is exact; is the first positive integer that is not.
binary64: 53-bit significand, max about , min normal , min subnormal , epsilon .
Custom formats
A problem may define its own small format. For exponent bits (bias , all-zeros and all-ones reserved) and fraction bits, the same reasoning gives
| Quantity | Value |
|---|---|
| Max finite | |
| Min positive normal | |
| Min positive subnormal |
For an 8-bit format with 1 sign bit, (bias 7) and : max finite , min normal , min subnormal . If the stem does not reserve the all-ones exponent, or gives a different bias, recompute from the stem.

How it works
Encode an exactly representable finite nonzero normal (binary32)
- This recipe assumes an exactly representable significand with at most 24 significant binary digits; inexact inputs require rounding and possible renormalization/range checking before packing. Write the number as with and in .
- Store . Store . Store the 23 bits of after the leading 1.
Example. : , , . Bits 0 01111111 00000000000000000000000 = 0x3F800000.
Example. : , bits 0x40000000.
Example. : , bits 0x3F000000.
Example. : same as with sign 1, 0xBF800000.
Decode
If and : signed zero. If and : subnormal. If and : signed infinity. If and : NaN. Else normal with the formula above.
Why is inexact
is recurring in binary (). The binary32 encoding rounds to the nearest representable value with bits 0x3DCCCCCD, whose exact value is . For inexact computations where approximate agreement is intended, use suitable absolute/relative tolerances. Exact equality remains appropriate when the specification requires exact identity.
Ordering
Because the exponent is biased and sits above the fraction, finite encodings with sign bit 0 (positive zero included) sort in value order when read as unsigned integers. Negative zero is excluded unless both zero encodings are first normalized. Negative finite encodings sort in reverse; NaNs are outside numerical order.
Algorithms and pseudocode
Pseudocode for field extraction on an unsigned 32-bit pattern u:
FIELDS32(u)
1 s <- (u >> 31) AND 1
2 E <- (u >> 23) AND 0xFF
3 f <- u AND 0x7FFFFF
4 return (s, E, f)
DECODE32(u)
1 (s, E, f) <- FIELDS32(u)
2 if E = 255 then
3 if f = 0 then return (-1)^s * infinity else return NaN
4 if E = 0 then
5 if f = 0 then return (-1)^s * 0
6 else return (-1)^s * (f * 2^(-23)) * 2^(-126)
7 return (-1)^s * (1 + f * 2^(-23)) * 2^(E-127)
ENCODE32(x) // x finite, nonzero, in the normal range, exact in 24 bits
1 s <- 1 if x < 0 else 0; x <- |x|
2 e <- 0
3 while x >= 2: x <- x / 2; e <- e + 1
4 while x < 1: x <- x * 2; e <- e - 1
5 f <- (x - 1) * 2^23 // an integer when x is exact
6 return (s << 31) OR ((e + 127) << 23) OR fCosts. In a fixed-width binary32 model with constant-time bit operations, tests and exact scaling by powers of two on bounded decoded values, FIELDS32 and DECODE32 take time and auxiliary words in best, average and worst cases, excluding fixed-size inputs/output. For ENCODE32 let . Its normalization executes exactly halvings or doublings and takes operations with working words. On its stated normal, exactly representable binary32 domain, : best is zero normalization iterations and worst is 127, so all cases, including any average distribution on this bounded domain, are in this model. This does not analyze arbitrary-precision inputs. When needs more than 24 significant bits, line 5 is not an integer and the result must be rounded (see Floating-Point Arithmetic).
Mathematical explanation
The normal set for binary32 is
together with subnormals, signed zeros, infinities and NaNs. Spacing between normals at exponent is (the unit in the last place, ulp). Relative precision is about in the binade.
Spacing grows with magnitude. Each binade holds exactly values, so the gap doubles from one binade to the next: just above 1, just above , and just above . The relative gap stays between and across all normals.
Decimal digits. significand bits give about decimal digits: and .
Worked examples
Example 1: fields of 0x3F800000
, , .
Example 2: encode
, , , 0xC0000000.
Example 3:
0x7F800000. is 0xFF800000.
Example 4: smallest positive subnormal
Pattern 0x00000001 decodes to . The largest subnormal, 0x007FFFFF, is , one step of below the smallest normal 0x00800000.
Example 5: quiet NaN pattern
0x7FC00000 has and fraction MSB set.
Example 6: decimal digits of precision
, so roughly 7 significant decimal digits for binary32; binary64 with gives about 15 to 16.
Example 7: encode
. So , , and . The pattern is 1 10000010 10110100000000000000000 = 0xC15A0000.
Example 8: decode 0x42F60000
Binary 0 10000101 11101100000000000000000: , , so ; significand . Value .
Example 9: first integer that does not fit
needs 25 significant bits. Binary32 rounds it to the nearest even neighbour, , because the gap above is 2.
Important properties and observations
- IEEE floats are not two's-complement integers; sorting by unsigned bit patterns works for finite encodings with sign bit 0, including positive zero; negative zero must be normalized separately, and signs and NaNs need separate treatment.
- Hidden bit applies only to normals; subnormals have leading 0.
- Casting a large float to int is a separate operation (undefined behaviour in C when the value does not fit); the encoding itself rounds to under the default round-to-nearest mode on overflow during floating arithmetic.
- Densest spacing is near zero (subnormals and small exponents); sparsest near the extremes of the exponent range.
- Subnormals have fewer significant bits:
0x00000001carries a single bit of precision.
Common misconceptions.
- "Exponent field stores the true exponent." It stores a biased exponent.
- "All reals in range are exact." Only specific dyadic values; most decimals are rounded.
- "NaN equals NaN." False under IEEE compare.
- "The minimum positive number is ." That is the minimum normal; subnormals go down to .
- "Precision is 23 bits." The hidden bit makes it 24 for normals.
GATE examination perspective
- FIELD SPLITS. 1+8+23 and 1+11+52 with biases 127 and 1023.
- SPECIAL PATTERNS. Identify zero, inf, NaN, subnormal from and .
- ENCODE/DECODE. Small values such as , and values like to hex.
- PRECISION. Hidden bit counted in significand width; ulp arguments; .
- RANGE. Max/min normal formulas, and the same formulas for a custom format in the stem.
Summary
Sources
- Floating-Point Numbers, MathWorks Fixed-Point Designer documentation, (consulted 2026-11-11): sign-magnitude layout, biased exponents (127, 1023), normalized and denormalized value formulas, gradual underflow, Inf and NaN encodings, quiet versus signaling NaN fraction MSB.
- P. Zimmermann, Floating-Point Training Module 1: The IEEE 754 Standard, (consulted 2026-11-11): binary32 extremal values and encodings (0x1, 0x800000, 0x7f7fffff), subnormal decoding, NaN and infinities, and the result that the difference of two distinct binary32 numbers is never rounded to zero.