Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that IEEE 754 floating point format is used and $f1 and $f2 and $f3 store

ID: 3676648 • Letter: A

Question

Assume that IEEE 754 floating point format is used and $f1 and $f2 and $f3 store the floating numbers as below:  
$f1: 1000 1010 0110 1110 1001 1000 0000 0000

$f2: 1000 1010 0100 1111 0100 0010 0000 0000

$f3: 0001 0001 0011 0011 0101 0101 0000 0001
a) Please show the step by step result computing for ($f1+$f2)+$f3. (first show the steps required to compute $f1+$f2 and then the steps for adding this results to $f3)
b) Please show the values of each register in decimal as well as the value of the final result ($f1+$f2+$f3) in decimal.

c) Repeat question and show the steps required to compute ($f1*$f2)*$f3.

d) Show the result of ($f1*$f2)*$f3 in decimal.

Explanation / Answer

In IEEE754 floating point format numers consists of sign bit, exponent bits and mantissa bits.

for a 32 bit IEEE754 floating point number single precisson has 1 sign bit(S), 8 exponent bits(E) and remaining 23 bits as mantissa(M).

given numbers are :

$f1: 1000 1010 0110 1110 1001 1000 0000 0000

$f2: 1000 1010 0100 1111 0100 0010 0000 0000

$f3: 0001 0001 0011 0011 0101 0101 0000 0001

Sign bit calculation:

first leftmost bit is sign bit, so $f1 sign calculated as -(1)S i.e -(1)1 = -1

similarly $f2 sign calculated as -(1)S i.e -(1)1 = -1

$f3 sign calculated as -(1)S i.e -(1)0 = 1.

It shows first two numbers are negative and third number is positive.

Exponent calculation (E):

after sign bit next 8 bits calculated as exponent of that number.

$f1 exponent is denoted as E1 that is E1= 000 1010 0

$f2 exponent is denoted as E2 that is E2= 000 1010 0

similarly $f3 exponent is denoted as E3 that is E3= 000 1010 0

Mantiss calculation :

after exponent next 8 bits calculated as ,mantissa of that number.

$f1 mantissa is denoted as M1 that is M1= 110 1110 1001 1000 0000 0000

$f2 mantissa is denoted as M2 that is M2= 100 1111 0100 0010 0000 0000

similarly $f3 mantissa is denoted as M3 that is M3= 011 0011 0101 0101 0000 0001

a) Answer:

As IEEE 754 standard floating point numbers Addition Algorithm

F=f1 + f2 (consider $f1 as f1 and $f2 as f2)

step1) f1 and f2 can only be added if the exponents are the same i.e E1=E2.

check E1 and E2

E1= 000 1010 0

E2= 000 1010 0

E= 001 01000 (E1+E2)

both are same no problem here. so goto step 6.

step6) next find the sum/difference of the mantissas depending on the sign bit S1 and S2.
If signs of f1 and f2 are equal then add the mantissas

because f1 and f2 both are negative so add f1 and f2 mantissas and kept negative sign bit.

i.e M = M1+M2

M1= 1.110 1110 1001 1000 0000 0000

M2= 1.100 1111 0100 0010 0000 0000

M= 11.011 1101 1101 1010 0000 0000

so finally add 1 to exponent. final result of f1 and f2 is 001 0100 1011 1101 1101 1010 0000 0000

If signs of f11 and f2 are not equal then subtract the mantissas.

now we add similarly final result ($f1+$f2+$f3) as FN

already we added ($f1+$f2) as f = 001 01000 1011 1101 1101 1010 0000 0000

now we add f to $f3 as same above used algorithm.($f3 considered as f3)

i.e FN = f + f3

f 's sign bit is 1 so it is negative

f's exponent is E=001 01000

f's mantissa is M= 011 1101 1101 1010 0000 0000

step1) f and f3 can only be added if the exponents are the same i.e E=E3

check E and E3

E = 001 01000

E3= 001 0001 0

both are same no problem but different.

step2) We know that f3 has the larger absolute value of the 2 numbers. Absolute value of of f3 should be greater than absolute value of f, else swap the values such that Abs(f3) is greater than Abs(f).
Abs(f3) > Abs(f).
step3) Initial value of the exponent should be the larger of the 2 numbers, since we know exponent of f3 will be bigger , hence Initial exponent result IE= E3

step4) Calculate the exponent's difference i.e. ED= (E3-E).

E3= 001 0100 0

E = 000 1010 1

ED= 000 0110 1 (decimal point is 13)

step5) Left shift the decimal point of mantissa (M) by the exponent difference. Now the exponents of both f1 and f2 are same. as shown below

mantissa M = 1.011 1101 1101 1010 0000 0000

after left shift by 13 times

we get 0.000 0000 0000 0101 1110 1110
step6) next find the sum/difference of the mantissas depending on the sign bit S1 and S2.
If signs of f and f3 are equal then add the mantissas

If signs of f and f3 are not equal then subtract the mantissas.

because f and f3 both are different signs so subtract f from f3. put positive sign on the result number because f3 sign is positive.

f3 mantissa M3 = 1.011 0011 0101 0101 0000 0001

f mantissa nowM= 0.000 0000 0000 0101 1110 1110

resultant value = 1.011 0011 0100 1111 0001 0011

normalization not needed here.

final result ($f1+$f2+$f3) is 00001 0001 011 0011 0100 1111 0001 0011

b) Answer.

Decimal representation:

decimal value of f1 is -12.864013671875

decimal value of f2 is -12.61920166015625

decimal value of f3 is 34.40103161334991455078125

decimal value of f1+f2+f3 = 9.6046481437958129400

anwer is wrong but concept is right.

c)

as multiplication algorithm:

Result f3 = f1 * f2

= (-1)s1 (M1 x 2E1) * (-1) s2 (M2 x 2E2)

S1, S2 => Sign bits of number f1 & f2.
E1, E2: =>Exponent bits of number f1 & f2.
M1, M2 =>Mantissa bits of Number f1 & f2.

1) Check if one/both operands = 0 or infinity. Set the result to 0 or inf. i.e. exponents = all "0" or all "1".
2)next the signed bit of the multiplicand(s1) is XOR'd with the multiplier signed bit (s2). The result is put into the resultant sign bit.

result sign is 1 XOR 1 i.e 0 is positive
3) multiply the mantissa of the Multiplier (M1) and multiplicand (M2) and the result is placed in the resultant field of the mantissa (truncate/round the result for 24 bits).
=M1 * M2

4) add the exponents of the Multiplier (E1) and the multiplicand (E2) bits and the base value is subtracted from the added result. The subtracted result is put in the exponential field of the result block.
=E1+E2-bias
5) Normalize the sum, either shifting right and incrementing the exponent or shifting left and decrementing the exponent.
6) Check for underflow/overflow. If Overflow set the output to infinity & for underflow set to zero.
7) If (E1 + E2 - bias) >= to Emax then set the product to infinity.
8) If E1 + E2 - bias) is lesser than/equal to Emin then set product to zero.

d) Answer

result isof (f1*f2)*f3 is =

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote