In: Computer Science
Given the following 32-bit binary sequences representing single precision IEEE
754 floating point numbers:
a = 0100 0000 1101 1000 0000 0000 0000 0000
b = 1011 1110 1110 0000 0000 0000 0000 0000
Perform the following arithmetic and show the results in both normalized binary format and IEEE 754 single-precision format. Show your steps.
a) a + b
b) a × b
a = 0 10000001 10110000000000000000000 sign bit is 0(+ve) exp bits are 10000001 Converting 10000001 to decimal 10000001 => 1x2^7+0x2^6+0x2^5+0x2^4+0x2^3+0x2^2+0x2^1+1x2^0 => 1x128+0x64+0x32+0x16+0x8+0x4+0x2+1x1 => 128+0+0+0+0+0+0+1 => 129 in decimal it is 129 so, exponent/bias is 129-127 = 2 frac bits are 1011 IEEE-754 Decimal value is 1.frac * 2^exponent IEEE-754 Decimal value is 1.1011 * 2^2 b = 1 01111101 11000000000000000000000 sign bit is 1(-ve) exp bits are 01111101 Converting 01111101 to decimal 01111101 => 0x2^7+1x2^6+1x2^5+1x2^4+1x2^3+1x2^2+0x2^1+1x2^0 => 0x128+1x64+1x32+1x16+1x8+1x4+0x2+1x1 => 0+64+32+16+8+4+0+1 => 125 in decimal it is 125 so, exponent/bias is 125-127 = -2 frac bits are 11 IEEE-754 Decimal value is 1.frac * 2^exponent IEEE-754 Decimal value is 1.11 * 2^-2 a) a + b = 1.1011 * 2^2 - 1.11 * 2^-2 = 1.1011 * 2^2 - 0.000111 * 2^2 = 1.100101 * 2^2 single precision: -------------------- sign bit is 0(+ve) exponent bits are (127+2=129) => 10000001 Divide 129 successively by 2 until the quotient is 0 > 129/2 = 64, remainder is 1 > 64/2 = 32, remainder is 0 > 32/2 = 16, remainder is 0 > 16/2 = 8, remainder is 0 > 8/2 = 4, remainder is 0 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10000001 So, 129 of decimal is 10000001 in binary frac/significant bits are 10010100000000000000000 so, a+b in single-precision format is 0 10000001 10010100000000000000000 b) a x b = 1.1011 * 2^2 x -1.11 * 2^-2 = 1.1011 x -1.11 = -10.111101 = -1.0111101 * 2^1 single precision: -------------------- sign bit is 1(-ve) exponent bits are (127+1=128) => 10000000 Divide 128 successively by 2 until the quotient is 0 > 128/2 = 64, remainder is 0 > 64/2 = 32, remainder is 0 > 32/2 = 16, remainder is 0 > 16/2 = 8, remainder is 0 > 8/2 = 4, remainder is 0 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10000000 So, 128 of decimal is 10000000 in binary frac/significant bits are 01111010000000000000000 so, a x b in single-precision format is 1 10000000 01111010000000000000000