Data Representation Flashcards
Practicing converting binary, hexa, octa
Convert the following numbers from hexadecimal to binary and to decimal
0x3F
0xDE
Answer:
Hexa: 0x3F
Binary: 0011111
Hexa: 0xDE
Binary: 11011110
Complete the following table, converting the binary numbers to decimal and decimal numbers to binary.
Binary to Decimal
11001110
01010101
Decimal to Binary
37
85
Answer:
Binary to Decimal 11001110 => 128 + 64 + 8 + 4 + 2 => 206 01010101 => 0x55 (another approach) (5 x 16^1) + (5 x 16^0) = 80 + 5 = 85 alternatively, 64 + 16 + 4 + 1 = 85
Decimal to Binary 37 => (37/2) a: 18 r: 1 => (18/2) a: 9 r: 0 => (9/2) a: 4 r: 1 => (4/2) a: 2 r: 0 => (2/2) a: 1 r: 0 => (1/2) a: 0 r: 1 => 00100101
alternatively, 85 => (85/16) a: 5 r: 5 => (5/16) a: 0 r: 5 => 0x55 => 01010101
Write an octal number which has the hexadecimal value 0xA6D.
Answer:
Hex to Binary to Octal
0xA6D => 1010 01101101 => 101 001 101 101
Octal: 5155 (base 8)
Consider the following declarations in the C language:
char x = -98;
unsigned char y = (unsigned char) x;
What is the decimal value of y?
Answer: y = 158
98 (unsigned) is 0x 62 => 01100010
2’s complement = 10011101 +1 => 10011110
=> 128 + 16 + 14 = 158