In: Computer Science
Please show all work:
Determine the 2’s complement equivalent of the following numbers in 8-bit format (N.B: You must show your work for full credit)!
1)Bit is the smallest unit in computers world.
2) 8 bit number means combinations of 0s and 1s.
For -12
For 2's complement we need two follow some rules
step 1) convert 12 in binary
12=00001100
replace left most bit with 1 two make it negative
-12 = 10001100
step 2) convert it into ones complement
for this you need to invert the given number (replace 1 by 0 and 0 by 1)
1's complement =
01110011
step 3) Add 1 to 1s complemt to convert it into 2's complement. (Binary addition are used and not normal mathematical addition because we are dealing in bits )
01110011
+1
01110100 ans
-------------------------------------------------------------------------
For -9
For 2's complement we need to follow some rules
step 1) convert 9 in binary
9 = 00001001
replace left most bit with 1 two make it negative
-9= 10001001
step 2) convert it into ones complement
for this you need to invert the given number (replace 1 by 0 and 0 by 1)
1's complement = 01110110
step 3) Add 1 to 1s complemt to convert it into 2's complement. (Binary addition are used and not normal mathematical addition because we are dealing in bits )
2's complement =
01110110
+1
01110111