Course contentsShow
← Computer Science
Lesson 1063 of 2,87225. Computer Architecture FoundationsFree lesson

Fixed-Point Number Representation

Representing fractional values by implicitly placing a binary point at a fixed position within an integer.

Fixed-Point Number Representation

What You'll Learn

You'll learn how computers can represent fractional numbers by treating an integer as if it has a decimal (or binary) point at a fixed position.

The Core Idea

So far, we've worked with integers—whole numbers like 5, -12, or 1024. But what about 3.75 or -0.5? One elegant solution is fixed-point representation: we store an integer, but pretend a binary point sits at a specific spot within its bits.

Think of it like measuring money in cents instead of dollars. When you see "1250," you mentally place a point two digits from the right: $12.50. The computer does the same thing with binary digits.

How It Works

Suppose you're using 8-bit two's complement integers, but you decide the rightmost 4 bits represent the fractional part. This gives you a Q4.4 format (4 integer bits, 4 fractional bits).

The binary number 00110100 would be interpreted as:

  • Integer part: 0011 = 3
  • Fractional part: 0100 = 4/16 = 0.25
  • Result: 3.25

The "point" never moves—it's always between bit 4 and bit 5. That's why it's called fixed-point.

Tradeoffs

You're still storing integers, so arithmetic uses normal integer operations! To add two Q4.4 numbers, just add the integers. But you sacrifice range: those 4 fractional bits mean your integer part can only reach 15 instead of 255.

The more bits you dedicate to the fractional part, the finer your precision—but the smaller your maximum value.

Key Takeaway:
Fixed-point representation lets computers handle fractional values using integer hardware by implicitly placing a binary point at a predetermined position, trading off range for fractional precision.