Académique Documents
Professionnel Documents
Culture Documents
2.4 Given n bits, how many unsigned integers can be represented with the n bits? What is the
range of these integers?
2.8
a. What is the largest positive number one can represent in an 8-bit 2's complement
representation?
b. What is the greatest magnitude negative number one can represent in an 8-bit 2's
complement representation. Write your result in binary and decimal.
c. What is the largest positive number one can represent in an 8-bit 2's complement
representation?
d. What is the greatest magnitude negative number one can represent in an 8-bit 2's
complement representation?
2.12 If the last digit of a 2's complement binary number is 0, then the number is even. If the last
two digits of a 2's complement number are 00 (eg. the binary number 01100) what does that tell
you about the number?
2.14 Add the following bit patterns. Leave your results in binary form.
a. 1011 + 0001
b. 0000 + 1010
c. 0101 + 0110
d. 1111 + 0001
2.40 Write the decimal equivalents for these IEEE floating point numbers.
a. 0 10000000 00000000000000000000000
b. 1 10000011 00010000000000000000000
c. 0 11111111 00000000000000000000000
d. 1 10000000 10010000000000000000000
Number Systems
2. Convert each of the following base 2 numbers to base 8, 10, and 16.
a. 1110001010001010110
b. 11010011011101111
4. Convert 555 which is a number in base 6 to the same value expressed in the bases
given below.
a. 4
b. 9
c. 12
Data Representation
5. Determine the data representation of each of the following integers assuming 16 bits are
used for each of the representations of sign and magnitude, ones complement, and twos
complement. Your answers must be expressed in hexadecimal.
a. 9355
b. -16094
6. Determine the data representation of each of the integers from question 5 again, but assume
32 bits are used and only show the representation for twos complement. Your answers must be
expressed in hexadecimal.
7. For each the following representations of 16 bit integers determine the integer values they
represent assuming each of a sign and magnitude, ones complement, and twos complement
representation.
a. FF4E
b. 70F1
8. Write the decimal value corresponding to each of these IEEE 32-bit floating point numbers as
expressed in hexadecimal. Note that the associated bits are from left to right: sign, exponent,
mantissa.
a. 40000000
b. C1880000
c. 40480000
9. For each of the following decimal values produce the 32-bit IEEE Floating Point
representation. Display your answer in binary clearly identifying the sign, exponent and
mantissa.
a. -1.2
b. 275.024
2.4Given n bits, how many unsigned integers can be represented with the n bits? What is
the range of these integers?
Solution-
2^n integers can be represented. The range would be 0 to (2^n) - 1.
2.8
a. What is the largest positive number one can represent in an 8-bit 2's complement
representation?
Solution-
Largest positive value with 8 bits
= (2n-1-1)
=27-1
=127 (in decimal)
In Binary = 01111111
b. What is the greatest magnitude negative number one can represent in an 8-bit 2's
complement representation. Write your result in binary and decimal.
Solution-
Greatest magnitude negative number one can represent in an 8-bit 2's complement representation
= -(2n-1-1)
= -(27-1)
= -128
In Binary = 10000000
c. What is the largest positive number one can represent in an 8-bit 2's complement
representation?
Solution-
= (2n-1-1)
d. What is the greatest magnitude negative number one can represent in an 8-bit 2's
complement representation?
Solution-
= -(2n-1-1)
2.12 If the last digit of a 2's complement binary number is 0, then the number is even. If the
last two digits of a 2's complement number are 00 (eg. the binary number 01100) what does
that tell you about the number?
Solution-It is a multiple of 4.
2.14 Add the following bit patterns. Leave your results in binary form.
a. 1011 + 0001
b. 0000 + 1010
c. 0101 + 0110
d. 1111 + 0001
Solution-
a) 1011 // Apply OR operation
+ 0001
1100
Q1.Write the decimal equivalents for these IEEE floating point numbers
a. 0 10000000 00000000000000000000000
Answer: 2.0
b. 1 10000011 00010000000000000000000
Answer: -17.0
c. 0 11111111 00000000000000000000000
Answer: Infinity
d. 1 10000000 10010000000000000000000
Answer: -3.125
a)
Identify the elements that make up the binary representation of the number:
The last 23 bits contain the mantissa: 000 0000 0000 0000 0000 0000
Convert the exponent, that is allways a positive integer, from binary (base 2) to decimal (base 10):
1000 0000(2) =
1 27 + 0 26 + 0 25 + 0 24 + 0 23 + 0 22 + 0 21 + 0 20
=128 + 0 + 0 + 0 + 0 + 0 + 0 + 0
=128
=128(10)
3. Adjust the exponent, subtract the excess bits, 2(8 - 1) - 1 = 127, that is due to the 8 bit excess/bias
notation:
Convert the mantissa, that represents the number's fractional part (the excess beyond the number's integer
part, comma delimited), from binary (base 2) to decimal (base 10):
0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0(10)
Put all the numbers into expression to calculate the single precision floating point decimal value:
(-1)0 (1 + 0) 21 =
1 21 =
2 Answer
b)
1 10000011 00010000000000000000000
Identify the elements that make up the binary representation of the number:
The last 23 bits contain the mantissa: 000 1000 0000 0000 0000 0000
2. Convert the exponent, that is allways a positive integer, from binary (base 2) to decimal (base 10):
1000 0011(2) = 1 27 + 0 26 + 0 25 + 0 24 + 0 23 + 0 22 + 1 21 + 1 20
= 128 + 0 + 0 + 0 + 0 + 0 + 2 + 1
= 128 + 2 + 1
= 131(10)
3. Adjust the exponent, subtract the excess bits, 2(8 - 1) - 1 = 127, that is due to the 8 bit excess/bias
notation:
4. Convert the mantissa, that represents the number's fractional part (the excess beyond the number's
integer part, comma delimited), from binary (base 2) to decimal (base 10):
0 + 0 + 0 + 0.062 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 =
0.062 5 =
0.062 5(10)
(-1)1 (1 + 0.062 5) 24 =
-1.062 5 24 =
-17
d)
1 10000000 10010000000000000000000
Identify the elements that make up the binary representation of the number:
The last 23 bits contain the mantissa: 100 1000 0000 0000 0000 0000
2. Convert the exponent, that is allways a positive integer, from binary (base 2) to decimal (base 10):
1000 0000(2) =
1 27 + 0 26 + 0 25 + 0 24 + 0 23 + 0 22 + 0 21 + 0 20 =
128 + 0 + 0 + 0 + 0 + 0 + 0 + 0 =128
Adjust the exponent, subtract the excess bits, 2(8 - 1) - 1 = 127, that is due to the 8 bit excess/bias
notation:
Exponent adjusted = 128 - 127 = 1
4. Convert the mantissa, that represents the number's fractional part (the excess beyond the number's
integer part, comma delimited), from binary (base 2) to decimal (base 10):
0.5 + 0 + 0 + 0.062 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 =
Put all the numbers into expression to calculate the single precision floating point decimal value:
(-1)1 (1 + 0.562 5) 21 =
-1.562 5 21 =
-3.125
NUMBER SYSTEMS
(9355)10 = (10010010001011)2
Base 8 conversion
8 9355
8 1169 3
8 146 1
8 18 2
2 2
Base 16 conversion
16 9355
16 584 11
16 36 8
2 4
b) Base 2 conversion
2 16094
2 8047 0
2 4023 1
2 2011 1
2 1005 1
2 502 1
2 251 0
2 125 1
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
1 1
(16094)10 = (11111011011110)2
Base 8 conversion
8 16094
8 2011 6
8 251 3
8 31 3
8 3 7
(16094)10 = (37336)8
Base 16 conversion
16 16094
16 1005 14
16 62 13
16 3 14
c) Convert each of the following base 2 numbers to base 8, 10, and 16.
a. 1110001010001010110
b. 11010011011101111
Solution-
a) Base 2 to Base 8
001 110 001 010 001 010 110
1 6 1 2 1 2 6
(1612126)8
Base 2 to Base 10
262144 131072 65536 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 1 0
262144+131072+65536+4096+2014+64+16+4+2
=463958 ANSWER
Base 2 to Base 16
0111 0001 0100 0101 0110
7 1 4 5 6
(71456)16 ANSWER
b) Base 2 to Base 8
(323357)8 ANSWER
Base 2 to Base 10
65536 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1 1 0 1 0 0 1 1 0 1 1 1 0 1 1 1 1
65536+32768+8192+1024+512+128+64+32+8+4+2+1
(108271)10 ANSWER
Base 2 to Base 16
a) A2D
Base 16 to Base 10
Base 10 to Base 2
2 2605
2 1302 1
2 651 0
2 325 1
2 162 1
2 81 0
2 40 1
2 20 0
2 10 0
2 5 0
2 2 1
2 1 0
(101000101101)2
Base 10 to Base 8
8 2605
8 325 5
8 40 5
5 0
(5055)8
b) 1055
Base 16 to Base 10
Base 10 to Base 2
2 4181
2 2090 1
2 1045 0
2 522 1
2 261 0
2 130 1
2 65 0
2 32 1
2 16 0
2 8 0
2 4 0
2 2 0
1 0
(1000001010101)2
Base 10 to Base 8
8 4181
8 522 5
8 65 2
8 8 1
1 0
(10125)8
4. Convert 555 which is a number in base 6 to the same value expressed in the bases given
below.
a. 4
b. 9
c. 12
a) 555
Base 6 to Base 10
= 60*5+61*5+62*5
=5+30+180
=(215)10
Base 10 to Base 4
4 215
4 53 3
4 13 1
4 3 1
(3113)4
Base 10 to Base 9
9 215
9 23 8
2 5
(258)9
Base 10 to Base 12
12 215
12 17 9
1 5
(159)12
5. Determine the data representation of each of the following integers assuming 16 bits are
used for each of the representations of sign and magnitude, ones complement, and twos
complement. Your answers must be expressed in hexadecimal.
a. 9355
b. -16094
a) 9355
0010010010001011
0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1
(248B)16 ANSWER
1s complement representation
0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1
(248B)16 ANSWER
2s complement representation
0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1
(248B)16 ANSWER
b). -16094
0011111011011110
Signed magnitude representation
1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0
(3EDE)16 ANSWER
1s complement representation
1100000100100001
1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1
(C121)16 ANSWER
2s complement representation
1100000100100010
1 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0
(C122)16 ANSWER
6. Determine the data representation of each of the integers from question 5 again, but assume
32 bits are used and only show the representation for twos complement. Your answers must be
expressed in hexadecimal.
a) 9355
00000000000000000010010010001011
0000248B
00000000000000000010010010001011
0000248B ANSWER
2. 1s complement representation
00000000000000000010010010001011
0000248B ANSWER
3. 2s complement representation
00000000000000000010010010001011
0000248B ANSWER
b) -16094
00000000000000000011111011011110
3EDE
10000000000000000011111011011110
80003EDE
2. 1s complement representation
11111111111111111100000100100001
FFFFC121
3. 2s complement representation
11111111111111111100000100100010
FFFFC122
7. For each the following representations of 16 bit integers determine the integer values they
represent assuming each of a sign and magnitude, ones complement, and twos complement
representation.
a. FF4E
b. 70F1
a)
65358
1111111101001110
1111111101001110
2. 1s complement representation
1111111101001110
3. 2s complement representation
1111111101001110
c) 70F1
28913
0111000011110001
0111000011110001
2. 1s complement representation
0111000011110001
3. 2s complement representation
0111000011110001
8. Write the decimal value corresponding to each of these IEEE 32-bit floating point numbers as
expressed in hexadecimal. Note that the associated bits are from left to right: sign, exponent,
mantissa.
a. 40000000
b. C1880000
c. 40480000
Solution:-
a) 40000000
+1 128 1.00000000000000000000000 (binary)
+1 * 2^(128 - 127) * 1
+1 * 2.00000000 * 1
2 Answer
b) C1880000
9. For each of the following decimal values produce the 32-bit IEEE Floating Point
representation. Display your answer in binary clearly identifying the sign, exponent and
mantissa.
a. -1.2
b. 275.024
a) -1.2
(bf99999a)16 ANS
b) 275.024
(43898312)16 ANS