Skip to content
V3.0 // STABLE
LOAD 12%
LAT 24MS
SLA 99.99%
Technical Article

Decoding IEEE 754: 32-bit Floating Point Numbers

4 min read
4 views
computer-sciencearchitecturemath

Have you ever wondered how computers, which only understand 0s and 1s, can store decimal numbers like 14.0 or 3.14? The answer lies in a clever standard called IEEE 754.

In this post, we'll break down how a 32-bit floating point number works, and we'll decode a real example together. Don't worry if it sounds complicated—we'll take it step by step!

The Anatomy of a 32-bit Float

A 32-bit floating point number is divided into three parts:

  1. Sign (S): 1 bit that tells us if the number is positive or negative.
  2. Exponent (E): 8 bits that determine the scale of the number (how big or small it is).
  3. Fraction (F): 23 bits that represent the actual digits of the number.

Here is a visual representation of how the 32 bits are laid out:

Live architecture
Analyzing Schema...

Arch Note

Interactive logic enabled. Click components in expanded view for technical service definitions.

Layer.0 / Distributed_System_Viz

(Note: The diagram above uses Mermaid's packet syntax to show the bit distribution)

The formula to convert this back to a decimal number is:

(-1)^S × 2^(E - 127) × (1 + F)

Let's break down a real problem using this formula.

The Problem

According to the IEEE-754 standard, which of the following is the decimal equivalent of the 32-bit floating point number given below? 01000001011000000000000000000000

a) 0.1875 b) 0.4375 c) 6.0 d) 14.0

Let's solve it step by step!

Step 1: Split the bits

First, we divide the 32-bit sequence into our three parts:

  • Sign (1 bit): 0
  • Exponent (8 bits): 10000010
  • Fraction (23 bits): 11000000000000000000000

Step 2: Determine the Sign (S)

The very first bit is 0.

  • 0 means the number is positive.
  • 1 means the number is negative.

So, S = 0. In our formula, (-1)^0 = 1.

Step 3: Calculate the Exponent (E)

The next 8 bits are 10000010. We need to convert this binary number to decimal.

Remember that each position in binary represents a power of 2:

  • 1 × 2^7 = 128
  • 0 × 2^6 = 0
  • 0 × 2^5 = 0
  • 0 × 2^4 = 0
  • 0 × 2^3 = 0
  • 0 × 2^2 = 0
  • 1 × 2^1 = 2
  • 0 × 2^0 = 0

Add them up: 128 + 2 = 130. So, E = 130.

The formula uses E - 127 (where 127 is called the "bias"). Our actual exponent power is 130 - 127 = 3. So, we will multiply by 2^3, which is 8.

Step 4: Calculate the Fraction (F)

The remaining 23 bits are 11000000000000000000000.

For the fraction part, we calculate powers of 2 going downwards starting from -1:

  • The first bit represents 2^{-1} (or 0.5)
  • The second bit represents 2^{-2} (or 0.25)
  • The third bit represents 2^{-3} (or 0.125), and so on.

Our fraction starts with 11 and the rest are 0s:

  • Bit 1 is 1 1 × 0.5 = 0.5
  • Bit 2 is 1 1 × 0.25 = 0.25
  • The rest are 0 0

Add them up: F = 0.5 + 0.25 = 0.75.

The formula uses (1 + F), so we get 1 + 0.75 = 1.75.

Step 5: Put it all together

Now we plug our values into the original formula:

(-1)^S × 2^(E - 127) × (1 + F)

  • Sign part: 1
  • Exponent part: 2^3 = 8
  • Fraction part: 1.75

1 × 8 × 1.75 = 14.0

The final decimal equivalent is 14.0.

[!TIP] Answer: The correct option is d) 14.0!

And that's how computers store decimal numbers! By breaking it down into Sign, Exponent, and Fraction, a simple string of 1s and 0s can represent a vast range of fractional values with incredible precision.