In: Computer Science
Q1: Translate the following Bytes to Decimal and Hexadecimal
a) 00001001
b) 111111111
c) 11101110
d) 01010101
a) 00001001
Decimal:
1 * 2^0 = 1 * 1 = 1
0 * 2^1 = 0 * 2 = 0
0 * 2^2 = 0 * 4 = 0
1 * 2^3 = 1 * 8 = 8
sum = 1 + 0 + 0 + 8 = 9
( 1001 )2 = ( 9 )10
Hexadecimal:
1001 |
9 |
( 1001 )2 = ( 9 )16
=======================================
b) 111111111
Decimal:
1 * 2^0 = 1 * 1 = 1
1 * 2^1 = 1 * 2 = 2
1 * 2^2 = 1 * 4 = 4
1 * 2^3 = 1 * 8 = 8
1 * 2^4 = 1 * 16 = 16
1 * 2^5 = 1 * 32 = 32
1 * 2^6 = 1 * 64 = 64
1 * 2^7 = 1 * 128 = 128
1 * 2^8 = 1 * 256 = 256
sum = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 = 511
( 111111111 )2 = ( 511 )10
Hexadecimal:
0001 | 1111 | 1111 |
1 | F | F |
( 111111111 )2 = ( 1FF )16
==================================== c) 11101110 Decimal: 0 * 2^0 = 0 * 1 = 0 1 * 2^1 = 1 * 2 = 2 1 * 2^2 = 1 * 4 = 4 1 * 2^3 = 1 * 8 = 8 0 * 2^4 = 0 * 16 = 0 1 * 2^5 = 1 * 32 = 32 1 * 2^6 = 1 * 64 = 64 1 * 2^7 = 1 * 128 = 128 Sum = 0 + 2 + 4 + 8 + 0 + 32 + 64 + 128 = 238 ( 11101110 )2 = ( 238 )10 Hexadecimal:
1110 | 1110 |
E | E |
( 11101110 )2 = ( EE )16
==================================== d) 01010101 Decimal: 1 * 2^0 = 1 * 1 = 1 0 * 2^1 = 0 * 2 = 0 1 * 2^2 = 1 * 4 = 4 0 * 2^3 = 0 * 8 = 0 1 * 2^4 = 1 * 16 = 16 0 * 2^5 = 0 * 32 = 0 1 * 2^6 = 1 * 64 = 64 Sum = 1 + 0 + 4 + 0 + 16 + 0 + 64 = 85 ( 1010101 )2 = ( 85 )10 Hexadecimal:
0101 | 0101 |
5 | 5 |
( 1010101 )2 = ( 55 )16