Fixed and Floating Point Representations — Data Representation


💡 Data Representation – Fixed and Floating Point Representations

Computers deal with numbers all the time — from counting your files to calculating distances in a video game.
But here’s the tricky part: computers can’t use “decimal points” like we do on paper. They only understand 0s and 1sbits!

So, how does a computer store numbers like 25, -3.5, or 0.0000042 using just 0s and 1s?
That’s where fixed-point and floating-point representations come in.


🧮 1. Fixed-Point Representation

Let’s start simple.

Imagine you’re writing numbers on paper but always keeping the decimal point in one fixed position.
That’s basically what a fixed-point representation does — the decimal (or binary point, in a computer) never moves.


🔹 How It Works

In fixed-point form:

  • Some bits are used for the whole number part (integer part).
  • Some bits are used for the fractional part (after the point).

The position of the point is fixed — it doesn’t change for different numbers.


🧠 Example

Suppose we have 8 bits, and we decide:

  • 5 bits for the integer part
  • 3 bits for the fractional part

So, a number like this:

10110.011

means:

  • Integer part: 10110 = 22
  • Fractional part: .011 = 0.375 (in decimal)
    → So, total = 22.375

Notice how the “binary point” is fixed after 5 bits.


⚙️ Key Point

Because the point is fixed, it’s great for simple calculations where precision and range are limited — like when you’re working with money or small measurements.

But there’s a catch — you can only represent numbers within a certain range.
If a number gets too big or too small, the fixed-point format can’t handle it.


🎯 Analogy

Think of fixed-point like a ruler that only measures between 0 and 30 cm with millimeter marks.
You can measure short distances very accurately, but if someone asks for 10 meters, you’re stuck!
You’d need a new ruler — or a new system — to handle larger values.


🌊 2. Floating-Point Representation

Now, let’s talk about the more flexible (and more magical) one — floating-point representation.

Here, the decimal (or binary) point can “float” — meaning it can move left or right depending on the number.
This allows computers to handle very large and very small numbers easily.


🔹 How It Works

In floating-point form, a number is split into three parts:

PartWhat it doesAnalogy
Sign bitTells whether the number is + or –Like a “+” or “–” sign
ExponentDecides where the point “floats”Like shifting the decimal point
Mantissa (or Significand)Holds the actual digits of the numberLike the main part of a number

So, the general formula is:

Value = (−1)^Sign × Mantissa × 2^(Exponent)

🧠 Example

Let’s say the floating-point number is stored like this (in binary):

0  10000010  10100000000000000000000

Breaking it down:

  • Sign bit (0) → Positive
  • Exponent (10000010) → 130 in decimal → (130 – 127 = 3, since we use a bias of 127)
  • Mantissa (1.101) → 1.625 in decimal

Now plug into the formula:

Value = +1.625 × 2^3 = 13.0

So, this binary pattern actually represents the number 13.0!


⚙️ Why Use Floating Point?

Floating-point is awesome because:

  • It can represent huge numbers (like distances between planets)
  • And tiny numbers (like size of an atom)
  • All using the same number of bits!

That’s why scientific calculators, physics simulations, and 3D games all depend on floating-point math.


🎯 Analogy

Imagine the floating-point system like scientific notation in math.

For example:

  • 3,000 = 3 × 10³
  • 0.0045 = 4.5 × 10⁻³

In both, the decimal “floats” — moving left or right to fit the number neatly.
Computers do the same thing, but in binary instead of decimal.


🧩 Diagram: Fixed vs Floating Point Representation

         +---------------------------------------------+
         |           Data Representation               |
         +----------------+-----------------------------+
                          |
          +---------------+----------------+
          |                                |
          v                                v
 +-----------------------+       +-----------------------------+
 |  Fixed Point Format   |       |  Floating Point Format       |
 +-----------------------+       +-----------------------------+
 | Sign | Integer | Fraction |  | Sign | Exponent | Mantissa  |
 | bit  |  bits   |  bits    |  | bit  |  bits    | bits      |
 +-----------------------+       +-----------------------------+
 | Decimal point is FIXED |      | Decimal point can FLOAT     |
 | Range is limited       |      | Large range of numbers      |
 | Example: 10110.011     |      | Example: 1.101 × 2^3        |
 +-----------------------+       +-----------------------------+

⚖️ Comparison Between Fixed and Floating Point

FeatureFixed PointFloating Point
Decimal/Binary PointFixedMoves (floats)
RangeSmallVery large
PrecisionHigh (for small numbers)Varies (can handle big/small)
SpeedFaster and simplerSlightly slower, more complex
Used inSimple devices, embedded systemsScientific and engineering apps

🌟 In Simple Words

  • Fixed Point: The point doesn’t move. Best for steady, small-range numbers.
    → Like having a ruler with fixed marks.
  • Floating Point: The point can move. Best for a huge range of values.
    → Like scientific notation that adapts to the number’s size.

💬 Real-Life Example

Imagine two friends measuring things:

  • Fixed-Point Fred uses a small ruler — great for measuring a pen, bad for a mountain.
  • Floating-Point Fiona uses a telescope and a microscope — she can measure stars or sand grains with equal ease.

That’s exactly how computers switch between fixed and floating-point systems depending on what they’re doing!