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

Core concepts

Binary32 and binary64 layouts

Bits are written MSB first (sign on the left).

FormatTotal bitsSignExponent bitsFraction bitsExponent bias
binary32 (single)321823127
binary64 (double)64111521023

Value of a normal finite number with sign ss, stored exponent field EE, and fraction field ff (interpreted as the bits after the binary point of the significand):

(−1)s⋅(1.f)2⋅2E−bias.(-1)^s \cdot (1.f)_2 \cdot 2^{E-\textit{bias}}.

The leading 1 before the point is the hidden bit (implicit bit); it is not stored for normals. For a kk-bit exponent field the bias is 2k−1−12^{k-1} - 1: 127 for 8 bits, 1023 for 11, 15 for the 5-bit field of binary16.

Exponent field regimes (binary32)

Stored EEMeaning
00zeros if f=0f=0; subnormals if f≠0f\neq 0
1..2541..254normals; true exponent e=E−127∈[−126,127]e=E-127\in[-126,127]
255255+∞+\infty/−∞-\infty if f=0f=0; NaN if f≠0f\neq 0

binary64 is analogous with E=0E=0 and E=2047E=2047 as the special endpoints and bias 1023; normal exponents run [−1022,1023][-1022,1023].

Subnormals

When E=0E=0 and f≠0f\neq 0,

(−1)s⋅(0.f)2⋅21−bias(-1)^s \cdot (0.f)_2 \cdot 2^{1-\textit{bias}}

(so binary32 multiplies by 2−1262^{-126}). 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 2−1262^{-126}, yet the next value above it is only 2−1492^{-149} further on. The hole between 0 and 2−1262^{-126} would be 2232^{23} times wider than the spacing just above it. Subnormals fill that hole with values spaced 2−1492^{-149} apart, the same spacing as in the lowest normal binade, so x−y=0x - y = 0 only when x=yx = y.

Zeros, infinities, NaNs

  • +0+0: all bits zero. −0-0: sign 1, other bits zero. They compare equal as floating values but are bit-distinct; 1/(+0)=+∞1/(+0)=+\infty and 1/(−0)=−∞1/(-0)=-\infty.
  • ±∞\pm\infty: EE all ones, f=0f=0.
  • NaN: EE all ones, f≠0f\neq 0. 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 0/00/0, ∞−∞\infty - \infty and 0×∞0 \times \infty produce NaN.
  • Counting patterns (binary32). Exponent 255 takes 2⋅223=2242 \cdot 2^{23} = 2^{24} patterns: 2 infinities and 224−22^{24} - 2 NaNs. The other 232−2242^{32} - 2^{24} patterns are finite numbers, including the two zeros.

Precision and range (binary32)

  • Precision: 24 significant bits counting the hidden 1 (23 stored + 1), about 24log⁡102≈7.224\log_{10}2 \approx 7.2 decimal digits.
  • Max finite: (2−2−23)⋅2127≈3.40×1038(2-2^{-23})\cdot 2^{127} \approx 3.40\times 10^{38}.
  • Min positive normal: 2−126≈1.18×10−382^{-126} \approx 1.18\times 10^{-38}.
  • Min positive subnormal: 2−149≈1.4×10−452^{-149} \approx 1.4\times 10^{-45}.
  • Machine epsilon (gap from 1.0 to the next value): 2−23≈1.19×10−72^{-23} \approx 1.19 \times 10^{-7}.
  • Every integer with magnitude up to 224=16,777,2162^{24} = 16{,}777{,}216 is exact; 224+12^{24} + 1 is the first positive integer that is not.

binary64: 53-bit significand, max about 1.80×103081.80\times 10^{308}, min normal 2−1022≈2.23×10−3082^{-1022} \approx 2.23 \times 10^{-308}, min subnormal 2−1074≈4.9×10−3242^{-1074} \approx 4.9 \times 10^{-324}, epsilon 2−52≈2.22×10−162^{-52} \approx 2.22 \times 10^{-16}.

Custom formats

A problem may define its own small format. For kk exponent bits (bias 2k−1−12^{k-1} - 1, all-zeros and all-ones reserved) and pp fraction bits, the same reasoning gives

QuantityValue
Max finite(2−2−p)⋅2bias(2 - 2^{-p}) \cdot 2^{\textit{bias}}
Min positive normal21−bias2^{1-\textit{bias}}
Min positive subnormal21−bias−p2^{1 - \textit{bias} - p}

For an 8-bit format with 1 sign bit, k=4k = 4 (bias 7) and p=3p = 3: max finite 1.875⋅27=2401.875 \cdot 2^{7} = 240, min normal 2−6=0.0156252^{-6} = 0.015625, min subnormal 2−9≈0.001952^{-9} \approx 0.00195. If the stem does not reserve the all-ones exponent, or gives a different bias, recompute from the stem.

IEEE 754 binary32 and binary64 field layouts with special-value examples
Figure 1. Field splits for binary32 (1+8+23) and binary64 (1+11+52), with example encodings of +1.0+1.0, −2.0-2.0, +0+0, +∞+\infty and a quiet NaN marked on the binary32 line.

How it works

Encode an exactly representable finite nonzero normal (binary32)

  1. 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 (−1)s⋅m⋅2e(-1)^s \cdot m \cdot 2^{e} with 1≤m<21\le m < 2 and ee in [−126,127][-126,127].
  2. Store ss. Store E=e+127E=e+127. Store the 23 bits of mm after the leading 1.

Example. +1.0=1.0⋅20+1.0 = 1.0\cdot 2^{0}: s=0s=0, E=127=011111112E=127=01111111_2, f=0f=0. Bits 0 01111111 00000000000000000000000 = 0x3F800000.

Example. +2.0=1.0⋅21+2.0 = 1.0\cdot 2^{1}: E=128E=128, bits 0x40000000.

Example. +0.5=1.0⋅2−1+0.5 = 1.0\cdot 2^{-1}: E=126E=126, bits 0x3F000000.

Example. −1.0-1.0: same as +1.0+1.0 with sign 1, 0xBF800000.

Decode

If E=0E=0 and f=0f=0: signed zero. If E=0E=0 and f≠0f\neq 0: subnormal. If E=255E=255 and f=0f=0: signed infinity. If E=255E=255 and f≠0f\neq 0: NaN. Else normal with the formula above.

Why 0.1100.1_{10} is inexact

0.1100.1_{10} is recurring in binary (0.00011‾20.0\overline{0011}_2). The binary32 encoding rounds to the nearest representable value with bits 0x3DCCCCCD, whose exact value is 0.1000000014901161193847656250.100000001490116119384765625. 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:

Text
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 f

Costs. 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 Θ(1)\Theta(1) time and O(1)O(1) auxiliary words in best, average and worst cases, excluding fixed-size inputs/output. For ENCODE32 let e=⌊lg⁡∣x∣⌋e=\lfloor\lg|x|\rfloor. Its normalization executes exactly ∣e∣|e| halvings or doublings and takes Θ(1+∣e∣)\Theta(1+|e|) operations with O(1)O(1) working words. On its stated normal, exactly representable binary32 domain, −126≤e≤127-126\le e\le127: best is zero normalization iterations and worst is 127, so all cases, including any average distribution on this bounded domain, are Θ(1)\Theta(1) in this model. This does not analyze arbitrary-precision inputs. When xx 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

{±(1+i⋅2−23) 2e:0≤i<223, −126≤e≤127}\bigl\{ \pm (1 + i\cdot 2^{-23})\, 2^{e} : 0\le i < 2^{23},\ -126\le e\le 127 \bigr\}

together with subnormals, signed zeros, infinities and NaNs. Spacing between normals at exponent ee is 2e−232^{e-23} (the unit in the last place, ulp). Relative precision is about 2−242^{-24} in the binade.

Spacing grows with magnitude. Each binade [2e,2e+1)[2^e, 2^{e+1}) holds exactly 2232^{23} values, so the gap doubles from one binade to the next: 2−232^{-23} just above 1, 11 just above 2232^{23}, and 22 just above 2242^{24}. The relative gap stays between 2−242^{-24} and 2−232^{-23} across all normals.

Decimal digits. pp significand bits give about plog⁡102p \log_{10} 2 decimal digits: 24×0.30103≈7.224 \times 0.30103 \approx 7.2 and 53×0.30103≈15.9553 \times 0.30103 \approx 15.95.

Worked examples

Example 1: fields of 0x3F800000

s=0s=0, E=127E=127, f=0f=0 ⇒+1.0\Rightarrow +1.0.

Example 2: encode −2.0-2.0

s=1s=1, e=1e=1, E=128E=128, f=0f=0 ⇒\Rightarrow 0xC0000000.

Example 3: +∞+\infty

0x7F800000. −∞-\infty is 0xFF800000.

Example 4: smallest positive subnormal

Pattern 0x00000001 decodes to 2−1492^{-149}. The largest subnormal, 0x007FFFFF, is (1−2−23)⋅2−126(1 - 2^{-23}) \cdot 2^{-126}, one step of 2−1492^{-149} below the smallest normal 0x00800000.

Example 5: quiet NaN pattern

0x7FC00000 has E=255E=255 and fraction MSB set.

Example 6: decimal digits of precision

2−24≈5.96×10−82^{-24}\approx 5.96\times 10^{-8}, so roughly 7 significant decimal digits for binary32; binary64 with 2−532^{-53} gives about 15 to 16.

Example 7: encode −13.625-13.625

13.625=1101.1012=1.1011012×2313.625 = 1101.101_2 = 1.101101_2 \times 2^3. So s=1s = 1, E=3+127=130=100000102E = 3 + 127 = 130 = 10000010_2, and f=1011010⋯0f = 1011010\cdots0. The pattern is 1 10000010 10110100000000000000000 = 0xC15A0000.

Example 8: decode 0x42F60000

Binary 0 10000101 11101100000000000000000: s=0s = 0, E=133E = 133, so e=6e = 6; significand 1.1110112=1.9218751.111011_2 = 1.921875. Value 1.921875×64=123.01.921875 \times 64 = 123.0.

Example 9: first integer that does not fit

16,777,217=224+116{,}777{,}217 = 2^{24} + 1 needs 25 significant bits. Binary32 rounds it to the nearest even neighbour, 16,777,21616{,}777{,}216, because the gap above 2242^{24} 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 ±∞\pm\infty 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: 0x00000001 carries 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 2−1262^{-126}." That is the minimum normal; subnormals go down to 2−1492^{-149}.
  • "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 EE and ff.
  • ENCODE/DECODE. Small values such as ±1,±2,0.5\pm 1, \pm 2, 0.5, and values like −13.625-13.625 to hex.
  • PRECISION. Hidden bit counted in significand width; ulp arguments; 224+12^{24} + 1.
  • RANGE. Max/min normal formulas, and the same formulas for a custom format in the stem.

Summary

Sources

  1. 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.
  2. 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.

Next steps