What We Will Cover

  1. How the Bit Splits (1 + 8 + 23 and 1 + 11 + 52) Were Chosen.
  2. Step-by-Step Mathematical Derivation of the Minimum and Maximum values for float and double.

Part 1: How the Bit Allocations Were Decided

The IEEE 754 standard committee designed these exact bit widths to balance dynamic range (how large or small numbers can get) against precision (how many significant digits you can trust), while fitting neatly into standard computer word architectures (32-bit and 64-bit registries).

Component32-bit Float Split64-bit Double SplitWhy This Choice?
Sign ()1 bit1 bitThe absolute bare minimum required to distinguish positive () from negative ().
Exponent ()8 bits11 bitsControls the magnitude (). 8 bits gives values (giving float a range of ). 11 bits gives values (giving double a massive range of ).
Mantissa ()23 bits52 bitsControls precision. 23 bits yields roughly distinct fractions (~7 decimal digits of precision). 52 bits yields roughly distinct fractions (~15-17 decimal digits of precision).
Total32 bits64 bitsPerfectly fits standard 32-bit and 64-bit CPU registers and memory bus widths[cite: 2].

Part 2: The Formula for Floating-Point Values

Unlike integers (which use two’s complement and count sequentially), floating-point numbers use scientific notation in binary: Where:

  • is the sign bit ( or ).
  • is the normalized mantissa with an implicit leading 1.
  • is the raw binary value of the exponent bits.
  • is a fixed offset () designed to allow negative exponents without needing a separate sign bit for the exponent.

Part 3: Calculating Min and Max for 32-bit Float

1. Exponent Details for Float (8 bits)

  • Total bit patterns: (from 00000000 to 11111111).
  • Reserved patterns:
    • (00000000) is reserved for zeros and subnormal numbers.
    • (11111111) is reserved for Infinities and NaN.
  • Usable normalized exponent range (): to .
  • Bias Calculation: .
  • Actual Exponent Range ():
    • Minimum normalized .
    • Maximum normalized .

2. Maximum Float Value (Float.MAX_VALUE)

To get the maximum positive value, we maximize every component:

  • Sign (positive)
  • Exponent (so )
  • Mantissa () Since , this evaluates to:

3. Minimum Positive Normalized Float

  • Sign
  • Exponent (so )
  • Mantissa () (Note: Java’s Float.MIN_VALUE actually returns the smallest possible subnormal number where and the final bit of the mantissa is , which equals ).

Part 4: Calculating Min and Max for 64-bit Double

1. Exponent Details for Double (11 bits)

  • Total bit patterns: (from 0 to 2047).
  • Reserved patterns: and .
  • Usable normalized exponent range (): to .
  • Bias Calculation: .
  • Actual Exponent Range ():
    • Minimum normalized .
    • Maximum normalized .

2. Maximum Double Value (Double.MAX_VALUE)

  • Sign
  • Exponent (so )
  • Mantissa ()

3. Minimum Positive Normalized Double

  • Sign
  • Exponent (so )
  • Mantissa () (Subnormal minimum for double is ).

How the Decimal Exponent Ranges ( and ) Are Calculated

To understand how binary exponent limits convert into base-10 ranges ( and ) and where the sign comes from, we bridge binary powers () to decimal powers () using logarithms.

1. Where Does the Sign Come From?

The sign comes from two factors working together:

  1. The Sign Bit (): The 1st bit of any float or double is strictly a sign bit ( for positive, for negative). This means every magnitude can be either positive or negative, giving us .
  2. The Exponent Bias: Because we want to represent both extremely large numbers (multiplying by massive powers of 2) and extremely small numbers close to zero (multiplying by tiny fractions like ), the exponent field must span both positive and negative values.
    • For a 32-bit float, the unbiased exponent range is from to .
    • For a 64-bit double, the unbiased exponent range is from to . Multiplying by scales a number down toward zero (microscopic), while multiplying by scales it up (astronomical).

2. Converting Base-2 Exponents to Base-10 ()

We want to know: If a float’s maximum base-2 exponent is roughly , what is that equivalent to in base-10 ()? We set up an equation where a power of 2 equals a power of 10: To solve for , we take the logarithm base 10 () of both sides: Using log rules ( and ):

Calculating the Value:

  • We know .
  • Therefore: . This means is roughly equal to , which gives us the approximate ceiling of . Applying the same logic to the minimum negative exponent (): Combined with the sign bit, this yields the total range: .

3. The Same Math for 64-bit Double ()

For a 64-bit double, the maximum unbiased exponent is : Rounding up gives us roughly . For the minimum negative exponent (): Combined with the sign bit and minimum/maximum scales, this gives double its massive range of .

Reference

https://medium.com/@kaustubh.saha/floating-point-numbers-and-their-java-representation-part-1-ae0f8b5436a4