You are designing an instruction set for an embedded system and have decided to use a 16-bit representation for integers and floating point numbers.
What is the 16-bit binary representation (in hexadecimal using lower-case letters, e.g., 0x39ab) of -13 (base 10) when represented as a two’s complement integer?
Solution:
=>Given decimal number = -13 in 2's complement form
Explanation:
Finding 16 bit binary representation of 13:
=>16 bit binary representation of 13 = 0000000000001101
Finding 1's complement of binary representation:
=>1's complement can be found by just flipping each bit of binary number.
=>1's complement of 0000000000001101 = 1111111111110010
Finding 2's complement of number:
=>2's complement represent of -13 = 1's complement of 13 + 1
=>2's complement represent of -13 = 1111111111110010 + 1
=>2's complement represent of -13 = 1111111111110011
Converting the number in hexadecimal form:
=>Grouping 4 bits each of binary number then writing hex value for each group of 4 bits
=>Hexadecimal value of -13 = 0xfff3
I have explained each and every part with the help of statements attached to the answer above.
Get Answers For Free
Most questions answered within 1 hours.