In: Computer Science
1) given the 8-bit binary number of 10111110 (two)
a)what is the hex representation of this number/
b) what is the decimal value if this number which is an 8-bit number as a two complement signed number. all steps included
c)what is the decimal value of this number as an 8-bit unsigned number, please write all steps
2) given the decimal number (-0.875) or (-7/8) convert it to single-precision floating-point. please show the easiest way to get to this,.
a) Hexadecimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 Use this table to convert from binary to hexadecimal Converting 10111110 to hexadecimal 1011 => B 1110 => E So, in hexadecimal 10111110 is 0xBE Answer: 0xBE b) since left most bit is 1, this number is negative number. so, follow these steps below to convert this into a decimal value. I. first flip all the bits. Flip all 0's to 1 and all 1's to 0. 10111110 is flipped to 01000001 II. Add 1 to above result 01000001 + 1 = 01000010 III. Now convert this result to decimal value => 1000010 => 1x2^6+0x2^5+0x2^4+0x2^3+0x2^2+1x2^1+0x2^0 => 1x64+0x32+0x16+0x8+0x4+1x2+0x1 => 64+0+0+0+0+2+0 => 66 Answer: -66 c) => 10111110 => 1x2^7+0x2^6+1x2^5+1x2^4+1x2^3+1x2^2+1x2^1+0x2^0 => 1x128+0x64+1x32+1x16+1x8+1x4+1x2+0x1 => 128+0+32+16+8+4+2+0 => 190 Answer: 190 d) Converting 0.875 to binary Convert decimal part first, then the fractional part > First convert 0 to binary Divide 0 successively by 2 until the quotient is 0 Read remainders from the bottom to top as So, 0 of decimal is in binary > Now, Convert 0.875 to binary > Multiply 0.875 with 2. Since 1.75 is >= 1. then add 1 to result > Multiply 0.75 with 2. Since 1.5 is >= 1. then add 1 to result > Multiply 0.5 with 2. Since 1.0 is >= 1. then add 1 to result > This is equal to 1, so, stop calculating 0.875 of decimal is .111 in binary so, 0.875 in binary is .111 -0.875 in simple binary => .111 so, -0.875 in normal binary is .111 => 1.11 * 2^-1 single precision: -------------------- sign bit is 1(-ve) exp bits are (127-1=126) => 01111110 Divide 126 successively by 2 until the quotient is 0 > 126/2 = 63, remainder is 0 > 63/2 = 31, remainder is 1 > 31/2 = 15, remainder is 1 > 15/2 = 7, remainder is 1 > 7/2 = 3, remainder is 1 > 3/2 = 1, remainder is 1 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 1111110 So, 126 of decimal is 1111110 in binary frac bits are 11000000000000000000000 so, -0.875 in single-precision format is 1 01111110 11000000000000000000000 in hexadecimal it is 0xBF600000