Here is the detailed explanation of Addition and Subtraction:

**There are three ways of representing negative fixed-point binary numbers:**

• Most computers use the **signed-2`s complement** representation when performing arithmetic operations with **integers**.

• For **floating-point operations**, most computers use the **signed-magnitude **representation for the mantissa.

## Note:

• It is important to realize that the adopted representation for negative numbers refers to the representation of numbers in the registers before and after the execution of the arithmetic operation.

## Rules for Addition & Subtraction Algorithm with Signed-Magnitude Data:

**1. **When the signs (+,-) of A and B are same, add the two magitudes and attach the sign of A to the result.

**2. **When the signs (+,-) of A and B are different, compare the magnitudes and subtract the smaller number from the larger.

- If A>B, use the sign of A
- If A<B, use the sign of B
- If A=B, subtract B from A and make the sign positive

## Hardware Implementation:

## Note:

To implement the two arithmetic operations with hardware, it is first necessary that the two numbers should be stored in registers. Let **A** and **B** be two registers that holds the magnitude of the numbers and **A _{s}** &

**B**be the two flip-flops that hold the corresponding signs

_{s}## Flowchart for Add and Subtract Operation:

## Addition and Subtraction of Floating Point Numbers:

During addition or subtraction, the two floating-point operands are kept in AC and BR. The sum or difference is formed in the AC.

**The algorithm can be divided into four consecutive parts:**

- Check for zeros.
- Align the mantissas.
- Add or subtract the mantissas
- Normalize the result

• A floating-point number cannot be normalized, if it is 0. If this number is used for computation, the result may also be zero. Instead of checking for zeros during the normalization process we check for zeros at the beginning and terminate the process if necessary. The alignment of the mantissas must be carried out prior to their operation. After the mantissas are added or subtracted, the result may be un-normalized. The normalization procedure ensures that the result is normalized before it is transferred to memory.

• If the magnitudes were subtracted, there may be zero or may have an underflow in the result. If the mantissa is equal to zero the entire floating-point number in the AC is cleared to zero. Otherwise, the mantissa must have at least one bit that is equal to 1. The mantissa has an underflow if the most significant bit in position A1, is 0. In that case, the mantissa is shifted left and the exponent decremented. The bit in A1 is checked again and the process is repeated until A1 = 1. When A1 = 1, the mantissa is normalized and the operation is completed.