In: Computer Science
Fill in the following table to show how the given integers are represented, assuming 16 bits are used to store values and the machine uses 2’s complement notation. (This is not necessarily MARIE.) Give values in the last two columns in hexadecimal as they would appear memory assuming the byte at address a is on the left and the byte at the address a+1 is on the right.
2-Byte Big |
2-Byte Little |
||||
Integer |
Binary |
Hex |
Endian (hex) |
Endian (hex) |
|
Example |
-540 |
1111 1101 1110 0100 |
FDE4 |
FD E4 |
E4 FD |
a) |
12 |
||||
b) |
-12 |
||||
c) |
128 |
||||
d) |
-128 |
||||
e) |
65,000 |
||||
f) |
-65,000 |
||||
byte a | byte a+1 |
byte a | byte a+1 |
Solution:
Integer | Binary | Hex | 2-Byte Big Endian (hex) | 2-Byte Little Endian (hex) | |
(a) | -540 | 1111 1101 1110 0100 | FDE4 | FD E4 | E4 FD |
(b) | 12 | 0000000000001100 | 000C | 00 0C | 0C 00 |
(c) | -12 | 1111111111110100 | FFF4 | FF F4 | F4 FF |
(d) | 128 | 0000000010000000 | 0080 | 00 80 | 80 00 |
(e) | -128 | 1111111110000000 | FF80 | FF 80 | 80 FF |
(f) | 65,000 | 1111110111101000 | FDE8 | FD E8 | E8 FD |
(g) | -65,000 | 0000001000011000 | 0218 | 02 18 | 18 02 |
Please give thumbsup, if you like it. Thanks.