In: Computer Science
represent -100 in 16-bit binary format and then convert it to Hexadecimal form.
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 100 successively by 2 until the quotient is 0
> 100/2 = 50, remainder is 0
> 50/2 = 25, remainder is 0
> 25/2 = 12, remainder is 1
> 12/2 = 6, remainder is 0
> 6/2 = 3, remainder is 0
> 3/2 = 1, remainder is 1
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1100100
So, 100 of decimal is 1100100 in binary
Adding 9 zeros on left hand side of this number to make this of length 16
So, 100 in normal binary is 0000000001100100
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
0000000001100100 is flipped to 1111111110011011
Step 3:. Add 1 to above result
1111111110011011 + 1 = 1111111110011100
so, -100 in 2's complement binary is 1111111110011100
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 1111111110011100 to hexadecimal
1111 => F
1111 => F
1001 => 9
1100 => C
So, in hexadecimal 1111111110011100 is 0xFF9C
Answer: 0xFF9C