computer-systems-Architecture
Page 93
Subtraction of Two Signed Binary Numbers in 2's Complement Form
When negative numbers are in 2's complement, subtraction is simplified:
Take 2's complement of the subtrahend and add it to the minuend.
Discard the carry out of the sign bit position.
Relationship for Subtraction and Addition
The conversion from subtraction to addition can be expressed as:
(+A) - (+B) = (+A) + (-B)
(+A) - (-B) = (+A) + (+B)
2's Complement Example
Example: Subtracting (-6) - (-13) gives +7.
In binary (8 bits): 11111010 - 11110011
Convert subtraction to addition by taking 2's complement of -13, yielding +13 (binary: 00001101).
Perform binary addition: 11111010 + 00001101 = 100000111.
Discard the end carry: Result = 00000111 (+7).
Addition/Subtraction in Binary System
Both signed and unsigned numbers are processed using the same basic addition rules.
Computers utilize a common circuit to handle both types of arithmetic, with results interpreted by the user based on the assumed nature (signed or unsigned).
Overflow
When adding two n-digit numbers, if the sum requires n + 1 digits, an overflow occurs.
Paper calculations have no width limit, but digital computers have finite register widths, resulting in overflow detection issues.
Techniques in computers involve setting a flip-flop to indicate overflow.
Overflow Detection for Unsigned vs. Signed Numbers
Unsigned Addition: An overflow is indicated by a carry out from the most significant bit.
Signed Addition: The sign bit is vital.
Overflow cannot occur if one number is positive and the other is negative (result is less than larger original number).
Overflow can occur if both numbers are positive or negative.
Example Dealing with Positive/Negative Overflow
+70 and +80 exceed 8-bit limits (+150) in binary; proper carry checks reveal overflow state without sufficient bits.
Last carry should guide output sign, indicating overflow.
Fixed-Point Representation
Decimal Fixed-Point Representation
Involves binary codes for decimal digits; 4 bits per digit in forms like BCD.
Example: 4385 in BCD = 0100 0011 1000 0101, requiring 16 bits, more than pure binary.
Advantages & Disadvantages of Decimal Representation
Decimal processes require simplicity for human-computer interaction but counter storage inefficiency.
Some systems perform direct arithmetic on decimal data.
Signed Decimal Numbers Representation
Maintain similar structure to binary; 9's or 10's complement used.
Operates similarly to signed-2's complement for decimal numbers.
Floating-Point Representation
Components
Two parts: mantissa (fixed-point number) and exponent (designates position).
Example: +6132.789 represented as Fraction: +0.6132789 Exponent: +04.
Normalization & Precision
A number is normalized if the most significant digit of the mantissa is non-zero.
Nonnormalized numbers can be shifted to normalized format, changing exponents accordingly.
Arithmetic Complexity & Hardware
Floating-point operations are more complex than fixed-point, and although they require more time and circuitry, they are essential for scientific computations.
Bit Representation (Other Codes)
Gray Code
Characterized by single-bit transitions, beneficial for counters to minimize errors.
Decimal Codes
Many arrangements possible but entail more complexity; BCD is traditional but inefficient.
Excess-3 and 2421 codes offer self-complementing advantages for computation purposes.
ASCII Coding
7-bit codes for character representation; varies by application needs.
Error Detection Codes
Importance of Error Detection
With data being susceptible to errors, systems utilize codes to identify corrupted bits during transmission.
Common Parity Method
Adding parity bits to ensure the total number of 1's meets certain criteria (odd/even).
Implementing exclusive-OR functions for comparison.
Summary of Concepts
Binary numbers involve subcomponents for arithmetic; 2's complement conversion plays a critical role in signed arithmetic.
Overflows must be carefully monitored especially in fixed-width binary systems.
Despite added complexity, floating-point representation is crucial for scalability of computations.
As systems grow, robust error detection and data integrity methods foster reliability and trust.