This is representative of the kinds of topics and kind of questions you may be asked on the exam. In addition to this practice exam, you should also review:
8 * 10^5
1 * 2^7
14 * 16^4
0001 0011 2^4 + 2^1 + 2^0 = 16 + 2 + 1
2^0 + 2^2 + 2^3 + 2^4 + 2^6 + 2^7 = 1 + 4 + 8 + 16 + 64 + 128 = 221
Negation: 0010 0010 Add one: 0010 0011 2^0 + 2^1 + 2^5 = 1 + 2 +32 = 35 -35
Is it possible to tell if this number is in unsigned or two's complement representation? If yes, explain how. If not, explain why.
It's not possible to tell. Binary numbers are not self-describing. This could be an unsigned number, a two's complement number, a character, or any number of other things.
A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 2028 / 16^2 = 7, remainder 236 236 / 16^1 = 14 (E), remainder 12 12 / 16^0 = 12 (C), remainder 0 0x07EC 7 * 16^2 + 14 * 16^1 + 12 * 16^0 = 1792 + 224 + 12 = 2028
882 / 2^9 = 1, remainder 370 370 / 2^8 = 1, remainder 114 114 / 2^7 = 0, remainder 114 114 / 2^6 = 1, remainder 50 50 / 2^5 = 1, remainder 18 18 / 2^4 = 1, remainder 2 2 / 2^3 = 0, remainder 2 2 / 2^2 = 0, remainder 2 2 / 2^1 = 1, remainder 0 0 / 2^0 = 0, remainder 0 Unsigned magnitude: 0000 0011 0111 0010 (2^9 + 2^8 + 2^6 + 2^5 + 2^4 + 2^1 = 512 + 256 + 64 + 32 + 16 + 2 = 882) Flip bits: 1111 1100 1000 1101 Add one: 1111 1100 1000 1110 To hex: 0xFC8E
1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 1 + 0 1 0 0 0 1 0 1 ------------------------ 0 1 0 0 0 0 1 0 Carry set, overflow not set
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 + 1 0 0 0 0 0 0 0 ------------------------ 0 1 1 1 1 1 0 0 Carry set, overflow set
Flip bits: 0111 1111 Adding one achieved by an initial carry-in of 1 below: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 + 0 1 1 1 1 1 1 1 ------------------------ 0 1 1 1 1 1 0 0 Carry set, overflow not set
0x3F = 0011 1111 0x5A = 0101 1010 0 0 1 1 1 1 1 1 & 0 1 0 1 1 0 1 0 ------------------------ 0 0 0 1 1 0 1 0 0001 = 0x1 1010 = 0xA 0x1A
0x4E = 0100 1110 0xB2 = 1011 0010 0 1 0 0 1 1 1 0 | 1 0 1 1 0 0 1 0 ------------------------ 1 1 1 1 1 1 1 0 1111 = 0xF 1110 = 0xE 0xFE
0x7A = 0111 1010 0x14 = 0001 0100 0 1 1 1 1 0 1 0 ^ 0 0 0 1 0 1 0 0 ------------------------ 0 1 1 0 1 1 1 0 0110 = 0x6 1110 = 0xE 0x6E
0x8 = 1000 0x7 = 0111 Flip bits: 0111 1000
1000 1000
0011 0001
1111 0001
0001 0001
XXXX XXXX ? ???? ???? ----------- 0X00 0000 (wanted) X & 0 = 0 X & 1 = X X | 0 = X X | 1 = 1 XXXX XXXX & 0100 0000 (mask and operation) ----------- 0X00 0000
XXXX XXXX ? ???? ???? ----------- XXX1 XX1X (wanted) X & 0 = 0 X & 1 = X X | 0 = X X | 1 = 1 XXXX XXXX | 0001 0010 (mask and operation) ----------- XXX1 XX1X