In: Computer Science
Write the binary representation of the decimal number -64 (negative 64)
(64)10 =(1000000)2
--------------------------------------------------------------------------------------------
(i) IEEE 754 single precision format:
Sign(S)(1bit) | Exponent(E)(8bits) | Mantissa(M)(23bits) |
In Implicit form = (-1)S * 1.M * 2E-127
(-64)10 = (-1)1 * (1000000)2
= (-1)1 * (1.000000) *26
= (-1)1 * (1.000000) *26+127
= (-1)1 * (1.000000) *2133
Here, S=1, M=00000000, E= 133 = 10000101
(-64) in IEEE 754 single precision format =
1 | 10000101 | 00000000 |
--------------------------------------------------------------------------------------------------------
(ii) 8 bits 2's compliment representation:
(64)10 =(01000000)2
(-64)10 in 8 bits 2's complement =(11000000)2 ( ANSWER)
(-64)10 in 16 bits 2's complement =(1111111111000000)2
---------------------------------------------------------------------------------------------------------------------
(iii) Signed magnitude representation:
(-64)10 in 8 bits signed magnitude representation =(11000000)2
(-64)10 in 16 bits signed magnitude representation =(1000000001000000)2
---------------------------------------------------------
In 8 bits representation, both signed magnitude and 2's complement form looks same, but those two are different form if you see the 16 bits representation.