Assignment 4
Solutions to Problems on Information Representation
- Convert each of the following binary numbers into decimal (base 10).
- 1000000
Note that the rightmost bit represents 20, the bit to the left of that
represents 21, the third bit from the right represents 22,
and so on. In this case, there is only a single 1 at the 26 positions.
Note that 26 = 64, which is the decimal value of this bit pattern.
- 1101010
The 1's in this bit pattern are at positions (starting from the right)
21, 23, 25, and 26. Thus, the
decimal value of the binary number is 26+25+23+21
= 64 + 32 + 8 + 2 = 106.
- 10111011
27 + 25 + 24 + 23 + 21 + 20 =
128 + 32 + 16 + 8 + 2 + 1 =
187.
- 101011001
28 + 26 + 24 + 23 + 20 =
256 + 64 + 16 + 8 + 1 =
345.
- Give the binary representation for each of the following decimal numbers.
- 23
Note that 23 is the sum of the following powers of 2: 23 = 16 + 4 + 2 + 1, or
equivalently: 23 = 24 + 22 + 21 + 20.
So, the binary representation of 23 is the bit pattern: 1 0 1 1 1.
- 47
47 = 32 + 8 + 4 + 3 + 2 + 1. So, binary representation is: 1 0 1 1 1 1.
- 64
64 = 26. Binary representation: 1 0 0 0 0 0 0.
- 109
109 = 64 + 32 + 8 + 4 + 1. Binary representation: 1 1 0 1 1 0 1.
- For the each of the following if the number is in binary, give its Hexadecimal
representation; and if the number is in Hex, give its representation in binary.
- 1011011010101101
To convert to Hex, starting from the right divide bit pattern into groups of 4 bits (if
the leftmost set of bits is less than 4, then add some leading 0's to make it 4 bits).
Then convert each group of 4 bits into its binary equivalent.
1011 0110 1010 1101
B 6 A D
- 1011110111
0010 1111 0111
2 F 7
- D37A
D 3 7 A
1101 0011 0111 1010
- 6BC0E2
6 B C 0 E 2
0110 1011 1100 0000 1110 0010
- GIF images can have up to 256 colors (note that 256 is 28, so 8 bits
are required to represent all of the 256 different colors). Each pixel in the image
can be any of the available colors. Suppose that we have a GIF image with a size of
320x240 pixels. How many bytes is required to store this image?
The total number of pixels in the image is 320 x 240 = 76800. Each pixel requires
8 bits (or one byte). Thus, to store the image, we need 76800 bytes which is
75K bytes.
Back to Assignments
|