2025 26 2c

Computer Organization and Architecture2025-267 marksNumericalFloating point arithmetic operation

Explain floating point arithmetic operations. Perform floating point addition using IEEE 754 format for (5.75)10 + (-2.5)10.

Explain floating point arithmetic operations. Perform floating point addition using IEEE 754 format for (5.75)10 + (-2.5)10.

Floating point numbers are stored as sign, exponent and mantissa, so their arithmetic needs extra steps on the exponents.

Addition and subtraction. (1) Compare the exponents. (2) Shift the mantissa of the smaller number right, and raise its exponent by 1 for every shift, until the exponents are equal. (3) Add or subtract the mantissas. (4) Normalise the result so it is again in the form $1.f$, and adjust the exponent. (5) Round the result and check for overflow or underflow.

Multiplication. Add the exponents, subtract the bias, multiply the mantissas, and normalise. The sign is the XOR of the signs.

Division. Subtract the exponents, add the bias, divide the mantissas, and normalise.

Example: $5.75 + (-2.5)$ in IEEE 754 single precision

In binary, $5.75 = 101.11_2 = 1.0111_2 \times 2^{2}$ and $2.5 = 10.1_2 = 1.01_2 \times 2^{1}$. The stored exponents are $2 + 127 = 129 = 10000001$ and $1 + 127 = 128 = 10000000$. So:

NumberSignExponentFraction
5.7501000000101110000000000000000000
-2.511000000001000000000000000000000

The exponents differ by 1, so shift the mantissa of $-2.5$ one place right. It becomes $-0.101_2 \times 2^{2}$.

The signs differ, so this is a subtraction of the mantissas:

$$1.0111 - 0.1010 = 0.1101$$

The result is $0.1101_2 \times 2^{2}$. It is not normalised, so shift left by one place and reduce the exponent by 1:

$$0.1101_2 \times 2^{2} = 1.101_2 \times 2^{1}$$

The sign is $0$, the stored exponent is $1 + 127 = 128 = 10000000$, and the fraction is $10100000000000000000000$.

SignExponentFraction
01000000010100000000000000000000

In hexadecimal this is $\text{0x40500000}$. The value is $1.101_2 \times 2 = 11.01_2 = 3.25$. Therefore $5.75 + (-2.5) = 3.25$, which is correct.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.

Up nextExplain different types of instructions. Explain various instruction formats with suitable