Question

In: Computer Science

2) Show how each of the following signed, decimal integers would be stored in 16-bit two's...

2) Show how each of the following signed, decimal integers would be stored in 16-bit two's complement format. Give your answer in hexadecimal.

a) -21 (5 points)

b) 4096 (5 points)

Solutions

Expert Solution

a)
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 21 successively by 2 until the quotient is 0
   > 21/2 = 10, remainder is 1
   > 10/2 = 5, remainder is 0
   > 5/2 = 2, remainder is 1
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10101
So, 21 of decimal is 10101 in binary
Adding 11 zeros on left hand side of this number to make this of length 16
So, 21 in normal binary is 0000000000010101
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   0000000000010101 is flipped to 1111111111101010
Step 3:. Add 1 to above result
1111111111101010 + 1 = 1111111111101011
so, -21 in 2's complement binary is 1111111111101011
Let's convert this to hexadecimal
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 1111111111101011 to hexadecimal
1111 => F
1111 => F
1110 => E
1011 => B
So, in hexadecimal 1111111111101011 is 0xFFEB
Answer: 0xFFEB

b)
Since this is a positive number. we can directly convert this into binary
Divide 4096 successively by 2 until the quotient is 0
   > 4096/2 = 2048, remainder is 0
   > 2048/2 = 1024, remainder is 0
   > 1024/2 = 512, remainder is 0
   > 512/2 = 256, remainder is 0
   > 256/2 = 128, remainder is 0
   > 128/2 = 64, remainder is 0
   > 64/2 = 32, remainder is 0
   > 32/2 = 16, remainder is 0
   > 16/2 = 8, remainder is 0
   > 8/2 = 4, remainder is 0
   > 4/2 = 2, remainder is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1000000000000
So, 4096 of decimal is 1000000000000 in binary
Adding 3 zeros on left hand side of this number to make this of length 16
so, 4096 in 2's complement binary is 0001000000000000
Let's convert this to hexadecimal
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 0001000000000000 to hexadecimal
0001 => 1
0000 => 0
0000 => 0
0000 => 0
So, in hexadecimal 0001000000000000 is 0x1000
Answer: 0x1000

Related Solutions

The unsigned decimal value (1,036)10 is to be stored as a 16-bit word in memory. Show...
The unsigned decimal value (1,036)10 is to be stored as a 16-bit word in memory. Show the 16-bit unsigned binary representation of (1,036)10. Show the 4-digit unsigned hexadecimal representation of (1,036)10. The unsigned binary value of part (a) should be stored using two bytes of a byte-addressable memory at locations 400 and 401. Specify the hexadecimal value in each byte for a “big endian” instruction set architecture. Give your answer by showing a table like the one below.                                                                                               ...
7.What is the hexadecimal equivalent of the 16-bit signed integer -32,760 ? *Note: answer in two's...
7.What is the hexadecimal equivalent of the 16-bit signed integer -32,760 ? *Note: answer in two's complement*
Assume -122 and -66 are signed 8-bit decimal integers. Calculate -122 + (- 66). and -122...
Assume -122 and -66 are signed 8-bit decimal integers. Calculate -122 + (- 66). and -122 - (- 66). Do we have overflow or underflow after each operation? Why?
Complete the following table. All binary numbers are 8-bit signed integers. (Don't forget to show the...
Complete the following table. All binary numbers are 8-bit signed integers. (Don't forget to show the steps of your solution!) Decimal value Sign-magnitude representation Ones' complement representation Two's complement representation -98 10001011 01110101 10100100 Compute the results of the indicated operations in columns 2 and 3, assuming that the binary numbers represent integers in the formats given by column 1. Identify which of the operations, if any, results in an overflow. (Don't forget to show the steps of your solution!)...
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively...
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively in the given order
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively...
Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively in the given order, separated by comma.
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
a)The decimal equivalent of the signed 2’s complement 8-bit binary number 11010101B is ______________. b)The decimal...
a)The decimal equivalent of the signed 2’s complement 8-bit binary number 11010101B is ______________. b)The decimal equivalent of the unsigned 8-bit hex number 0B4H is ______________. c)The value of the expression ‘H’ – ‘B’ is less than / equal to / greater than that of the expression ‘L’ – ‘C’. d)If the .data segment contains declarations                         A    BYTE      2 DUP (‘a’), ‘+’ B    BYTE      3 DUP (‘b’), 0 C    BYTE      4 DUP (‘c’), ‘–’ D    BYTE     ...
1. Complete the following table using 8-bit representation ((show your work to get credit) Decimal Signed...
1. Complete the following table using 8-bit representation ((show your work to get credit) Decimal Signed Magnitude One’s Complement Two’s Complement 30 -47 0
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT