Digital Logic · Signed Number Representation and Overflow
Radix Complement (B's Complement) and Diminished Radix Complement (B-1's Complement)
Overview
In a base- number system, a number can be rewritten in complementary form so that subtraction is performed by addition with an adder.
There are exactly two such systems: the B-1's complement (diminished radix complement) and the B's complement (radix complement), and they differ by exactly 1.
Key concepts
- Complementary number system: a way of writing a number in another form so that subtraction becomes easy using only addition (an adder).
- B's complement (radix complement): the complement of is , where is the radix and is the number of digits in .
It is called the radix complement because the radix is and the complement is taken with respect to . - B-1's complement (diminished radix complement): the complement of is . It is called the diminished radix complement because it uses , one less than the radix.
- For a given base , either system may be chosen; in either one, subtraction is converted into addition with an adder.
How it works
- Identify the radix and count the number of digits in the number .
- For the B-1's complement (diminished radix complement), compute .
- For the B's complement (radix complement), compute .
- Alternatively, obtain the B's complement by adding 1 to the B-1's complement.
Formulas
- B-1's complement (diminished radix complement) of : — = radix (base) of the number system, = number of digits in , = the given number.
- B's complement (radix complement) of : — = radix, = number of digits in , = the given number.
- Relationship: .
Comparison
| Property | B-1's complement | B's complement |
|---|---|---|
| Other name | Diminished radix complement | Radix complement |
| Formula | ||
| Relation | — | |
| Purpose | Makes subtraction easy using only an adder | Makes subtraction easy using only an adder |
Revision summary
- For any base there are exactly two complementary systems: B-1's complement and B's complement.
- B's complement = radix complement; B-1's complement = diminished radix complement.
- In both formulas, is the number of digits of , not of the base.
- Shortcut: B's complement = B-1's complement + 1 (just add 1 to the diminished radix complement).
- The whole point of complements: replace subtraction with addition using an adder.
Previous-year exam insights
- In 2's complement with n bits, the range is - to +-1; in 1's complement and sign-magnitude with n bits, the range is -(-1) to +(-1), and both have two representations of zero (+0 and -0).
Asked inGATE 2019GATE 2022 - Arithmetic overflow in n-bit 2's complement addition occurs only when two operands of the same sign produce a result of the opposite sign; adding operands of opposite signs can never overflow.
Equivalently, overflow = carry into the sign bit XOR carry out of the sign bit.
Asked inGATE 2022 - To find the 2's complement representation of a negative number -x in n bits: write x in n-bit binary, take the 1's complement (flip all bits), then add 1; equivalently .
The sign bit of a negative number is 1 and the MSB position has weight -.
Asked inGATE 2019 - In sign-magnitude representation, the magnitude field of an n-bit number holds n-1 bits, so the sum/difference of two n-bit sign-magnitude numbers may need n+1 bits to avoid overflow (one extra bit for the possible carry into the sign position).
Asked inGATE 2019 - IEEE-754 single precision: 1 sign bit, 8 biased exponent bits (bias 127), 23 fraction bits;
value = for normalized numbers.
E = 0 with F = 0 is zero, E = 0 with F ≠ 0 is denormal (value , and E = 255 is infinity/NaN. The smallest normalized positive number has E = 00000001 and F = 0.
Asked inGATE 2021GATE 2023 - For floating-point multiplication/division: multiply/divide the significands and add/subtract the true exponents, then re-bias; the sign is the XOR of the operand signs.
For addition/subtraction, align the exponents before operating.
Asked inGATE 2020GATE 2022GATE 2023