Explain the performance of Addition and Subtraction with signed magnitude data in computer architecture?

Computer ArchitectureComputer ScienceNetwork

A signed-magnitude method is used by computers to implement floating-point operations. Signed-2’s complement method is used by most computers for arithmetic operations executed on integers. In this approach, the leftmost bit in the number is used for signifying the sign; 0 indicates a positive integer, and 1 indicates a negative integer. The remaining bits in the number supported the magnitude of the number.

Example: -2410 is defined as −

10011000

In this example, the leftmost bit 1 defines negative, and the magnitude is 24.

The magnitude for both positive and negative values is the same, but they change only with their signs.

The range of values for the sign and magnitude representation is from -127 to 127.

There are eight conditions to consider while adding or subtracting signed numbers. These conditions are based on the operations implemented and the sign of the numbers.

The table displays the algorithm for addition and subtraction. The first column in the table displays these conditions. The other columns of the table define the actual operations to be implemented with the magnitude of numbers. The last column of the table is needed to avoid a negative zero. This defines that when two same numbers are subtracted, the output must not be - 0. It should consistently be +0.

In the table, the magnitude of the two numbers is defined by P and Q.

Addition and Subtraction of Signed Magnitude Numbers

OperationsAddition of Magnitudes         Subtraction of Magnitudes
(+P) + (+Q)+(P+Q)P>QP<QP=Q
(+P) + (-Q)
+(P-Q)-(Q-P)+(P-Q)
(-P) + (+Q)
-(P-Q)+(Q-P)+(P-Q)
(-P) + (-Q)-(P+Q)

(+P) - (+Q)
+(P-Q)-(Q-P)+(P-Q)
(+P) - (-Q)+(P+Q)

(-P) - (+Q)-(P+Q)

(-P) - (-Q)
-(P-Q)+(Q-P)+(P-Q)

As display in the table, the addition algorithm states that −

• When the signs of P and Q are equal, add the two magnitudes and connect the sign of P to the output.

• When the signs of P and Q are different, compare the magnitudes and subtract the smaller number from the greater number.

• The signs of the output have to be equal as P in case P > Q or the complement of the sign of P in case P < Q.

• When the two magnitudes are equal, subtract Q from P and modify the sign of the output to positive.

The subtraction algorithm states that −

• When the signs of P and Q are different, add the two magnitudes and connect the signs of P to the output.

• When the signs of P and Q are the same, compare the magnitudes and subtract the smaller number from the greater number.

• The signs of the output have to be equal as P in case P > Q or the complement of the sign of P in case P < Q.

• When the two magnitudes are equal, subtract Q from P and modify the sign of the output to positive.

Published on 24-Jul-2021 07:20:52