Introduction
Fixed-point representation places an implied binary point at a fixed position in a word: integer formats put it after the LSB, fractional formats before the MSB of the fraction field. Arithmetic uses the same adders as integer two's complement, with overflow and scaling rules. This note consolidates unsigned and two's-complement addition, subtraction, multiplication ranges, and overflow detection for GATE.
GATE asks which flags an addition sets, whether a signed or unsigned result overflowed, how many bits a sum or product needs, the range and resolution of a fixed-point format, and the effect of arithmetic shifts.
Prerequisites
- Signed Number Representation.
- Adder hardware: Adders and Subtractors.
Core concepts
Integer ranges
| Encoding (n bits) | Min | Max |
|---|---|---|
| Unsigned | 0 | |
| Two's complement |
Fractional fixed-point
A word with integer bits and fraction bits (, including sign if signed) represents multiples of . Scaling by converts to pure integer arithmetic: the pattern read as an integer stands for .
- Resolution (step): .
- Signed range (two's complement, sign bit counted in ): to .
- Unsigned range: to .
This note writes Q. with the sign bit counted in , so Q1.7 is an 8-bit signed fraction. Some texts write the same format as Q7 or Q0.7; check the stem's convention.
Converting a real number. Multiply by , round (or truncate) to an integer , then encode in two's complement only if is representable in the format. With no overflow, truncation error is below , and round-to-nearest error is at most . Reject an out-of-range value here; a separate saturation or wrap policy would not retain these quantization-only bounds.
Overflow and wrap
- Unsigned add: overflow iff final carry-out is 1 (for sum that should fit in bits).
- Unsigned subtract : a borrow (the result is wrong) iff ; with hardware that is carry-out 0.
- Two's complement add: overflow iff , equivalently same-sign operands with opposite-sign result.
- Two's complement subtract : overflow iff and have different signs and the result's sign differs from 's.
- Negation: overflows; it returns itself.
- Wrap-around still produces a defined pattern mod ; overflow means that pattern is not the mathematical sum.
Multiplication
- An unsigned product fits in bits; that width is required in the worst case for . For , the largest product is 1 and one bit suffices.
- Two's complement product also fits in bits. In fact bits hold every product except , which needs the full .
- For a signed product, truncating a product back to bits overflows when high bits are not a sign extension of the kept part. For unsigned arithmetic, overflow instead means some discarded high bit is nonzero.
- In fixed point, Q. times Q. gives Q.: the fraction bits add.
Sums of many terms
For positive integers , bits are a sufficient guard-bit bound for adding unsigned -bit numbers. The exact minimum width is . Doubling the term count adds at most one required bit.

How it works
Detecting signed overflow in hardware
Compute and from the adder; XOR them. Alternatively compare sign bits of operands and result:
Both forms give the same on every input pair.
Status flags together
After an -bit two's-complement add producing pattern :
- Z is 1 iff .
- N is the MSB of .
- C is the unsigned carry-out of the MSB.
- V is .
Over all 4-bit additions, only 9 of the 16 combinations of occur. and are never both 1, and when , is the complement of : a positive overflow has and , a negative overflow and . For in 4 bits (): , , , . For : with , , .
Borrow polarity. After , carry-out 1 means no borrow. Processor families differ in whether the stored flag is this carry or its complement (the borrow); follow the definition the question gives.
Shifts
- Arithmetic right shift by divides by and rounds toward (floor): , not .
- Left shift by 1 doubles the value and overflows (signed) when the two top bits differ before the shift.
Saturation (related material)
Related material. Some DSP datapaths clamp to min/max on overflow instead of wrapping. Saturation circuits are a DSP extension not named separately in the official syllabus.
Algorithms and pseudocode
Patterns are -bit integers; mod is the non-negative remainder.
ADD-DETECT(a, b, n, signed)
1 t <- a + b; s <- t mod 2^n; carry_out <- floor(t / 2^n)
2 if not signed then
3 ovf <- carry_out
4 else
5 ovf <- (sign(a)=sign(b)) and (sign(s)!=sign(a))
6 return (s, ovf)
SUB-DETECT(a, b, n, signed)
1 t <- a + (2^n - 1 - b) + 1; s <- t mod 2^n; carry_out <- floor(t / 2^n)
2 if not signed then ovf <- (carry_out = 0) // borrow
3 else ovf <- (sign(a)!=sign(b)) and (sign(s)!=sign(a))
4 return (s, ovf)
TO-FIXED(x, f, n) // real x to signed Q format, round to nearest
1 k <- round(x * 2^f)
2 if k < -2^(n-1) or k > 2^(n-1) - 1 then report overflow
3 return k mod 2^n
MUL-WIDTH(n)
1 return 2*n // bits to hold full productMathematical explanation
Identifying bit patterns with makes wrap modularly correct always. The signed interpretation is only faithful when the mathematical result lies in . Multiplication of two representatives corresponds to modular multiplication; the full signed product needs the double-width two's encoding.
Why detects overflow. If both operands are non-negative, , and the sign bit of the sum equals ; overflow (a negative-looking result) is exactly . If both are negative, , and overflow (a non-negative result) is exactly . With mixed signs the true sum lies between the operands, so it cannot overflow, and .
Product widths. For unsigned operands, . For signed operands, the largest magnitude is , one more than the -bit maximum ; every other product has magnitude at most , within bits.
Worked examples
Example 1: unsigned 4-bit
with carry 1: overflow, wrapped 1.
Example 2: signed 4-bit
(): overflow (both positive, result negative). Carry into sign 1, carry out 0, XOR 1.
Example 3: signed
(2): no overflow. Carry into sign 1 and carry out 1, so ; the unsigned carry is irrelevant here.
Example 4: the four cases of Figure 1
| Sum | Patterns | Result | Carry into sign | Carry out | |
|---|---|---|---|---|---|
| 1 | 0 | 1 | |||
| 1 | 0 | 1 | |||
| 0 | 1 | 1 | |||
| 1 | 1 | 0 |
Example 5: product width
in 4-bit two's (min ): 64 needs at least 8-bit two's (). The next largest, , already fits in 7 bits (range to ).
Example 6: Q1.3 format
Signed bit + 3 fraction bits; step ; range to . The value is the 4-bit two's-complement pattern of : .
Example 7: converting to Q1.7
, which rounds to 38 = . The stored value is , an error of , within the bound .
Example 8: signed subtraction overflow
In 4 bits, overflows: , which reads as . The operands have different signs and the result's sign differs from the minuend's. By contrast fits: , result .
Important properties and observations
- Logical shift and arithmetic shift differ on signed data (see signed-number note).
- Adding a positive to a negative never overflows in two's complement.
- Subtracting two numbers of the same sign never overflows.
- Flags in ALUs: Z (zero), N (sign), C (carry), V (overflow); definitions match the rules above.
- Sign-extend the shorter operand before adding numbers of different widths.
Common misconceptions.
- "Carry set means signed overflow." Only unsigned.
- " product fits in bits." Only with restrictions; generally needs .
- "Arithmetic right shift truncates toward zero." It floors: .
- "Q-format names are universal." Whether the sign bit is counted varies; read the stem.
GATE examination perspective
- WHICH FLAG. C vs V; when , .
- RANGE. State min/max before computing; Q. step .
- DOUBLE WIDTH. Product size; bits except .
- SAME-SIGN RULE. Fast overflow mental check; for subtraction, different signs.
- SHIFTS. Arithmetic right shift floors.
Summary
Sources
- M. Morris Mano, M. D. Ciletti, Digital Design, 5th ed., Pearson, 2013: Chapter 1, Sections 1.5 and 1.6, and Chapter 4, Section 4.5 (complements, signed numbers, adder-subtractor overflow context).