Vous êtes sur la page 1sur 17

Text Questions

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

1. Convert each of the following base 10 numbers to base 2, 8, and 16.


a. 9355
b. 16094

2. Convert each of the following base 2 numbers to base 8, 10, and 16.
a. 1110001010001010110
b. 11010011011101111

3. Convert each of the following base 16 numbers to base 2, 8, and 10.


a. A2D
b. 1055

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

b) 0000 // Apply OR operation


+ 1010
1010

c) 0101 // Apply OR operation


+ 0110
1011

d) 1111 // Apply OR operation


+ 0001
10000

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:

First bit (the leftmost) indicates the sign,


1 = negative, 0 = positive.

The next 8 bits contain the exponent: 1000 0000

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:

Exponent adjusted = 128 - 127 = 1

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):

000 0000 0000 0000 0000 0000(2) =


0 2-1 + 0 2-2 + 0 2-3 + 0 2-4 + 0 2-5 + 0 2-6 + 0 2-7 + 0 2-8 + 0 2-9 + 0 2-10 + 0 2-
11 + 0 2-12 + 0 2-13 + 0 2-14 + 0 2-15 + 0 2-16 + 0 2-17 + 0 2-18 + 0 2-19 + 0 2-20 +
0 2-21 + 0 2-22 + 0 2-23 =

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)Sign (1 + Mantissa) 2(Exponent adjusted) =

(-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:

First bit (the leftmost) indicates the sign,


1 = negative, 0 = positive.

The next 8 bits contain the exponent: 1000 0011

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:

Exponent adjusted = 131 - 127 = 4

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):

000 1000 0000 0000 0000 0000(2) =


0 2-1 + 0 2-2 + 0 2-3 + 1 2-4 + 0 2-5 + 0 2-6 + 0 2-7 + 0 2-8 + 0 2-9 + 0 2-10 + 0 2-
11 + 0 2-12 + 0 2-13 + 0 2-14 + 0 2-15 + 0 2-16 + 0 2-17 + 0 2-18 + 0 2-19 + 0 2-20 +
0 2-21 + 0 2-22 + 0 2-23 =

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)Sign (1 + Mantissa) 2(Exponent adjusted) =

(-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:

First bit (the leftmost) indicates the sign,


1 = negative, 0 = positive.

The next 8 bits contain the exponent: 1000 0000

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):

100 1000 0000 0000 0000 0000(2) =


1 2-1 + 0 2-2 + 0 2-3 + 1 2-4 + 0 2-5 + 0 2-6 + 0 2-7 + 0 2-8 + 0 2-9 + 0 2-10 + 0 2-
11 + 0 2-12 + 0 2-13 + 0 2-14 + 0 2-15 + 0 2-16 + 0 2-17 + 0 2-18 + 0 2-19 + 0 2-20 +
0 2-21 + 0 2-22 + 0 2-23 =

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 =

0.5 + 0.062 5 =0.562 5(10)

Put all the numbers into expression to calculate the single precision floating point decimal value:

(-1)Sign (1 + Mantissa) 2(Exponent adjusted) =

(-1)1 (1 + 0.562 5) 21 =

-1.562 5 21 =

-3.125

NUMBER SYSTEMS

1. Convert each of the following base 10 numbers to base 2, 8, and 16.


a. 9355
b. 16094
Solution-
a) Base 2 conversion
2 9355
2 4677 1
2 2338 1
2 1169 0
2 584 1
2 292 0
2 146 0
2 73 0
2 36 1
2 18 0
2 9 0
2 4 1
2 2 0
1 0

(9355)10 = (10010010001011)2
Base 8 conversion
8 9355
8 1169 3
8 146 1
8 18 2
2 2

(9355)10 = (22213)8 ANSWER

Base 16 conversion

16 9355
16 584 11
16 36 8
2 4

(9355)10 = (248B)16 ANSWER

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

(16094)10 = (3EDE)16 ANSWER

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

011 010 011 011 101 111


3 2 3 3 5 7

(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

0001 1010 0110 1110 1111


1 10 6 13 15
(1A6EF)16 ANSWER
3. Convert each of the following base 16 numbers to base 2, 8, and 10.
a. A2D
b. 1055

a) A2D

Base 16 to Base 10

160*13+ 161*2+ 162*10


= 13+32+2560
=(2,605)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

=160*5+ 161*5+ 162*0+163*1


=5+80+4096
= (4181)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

CONVERT TO BINARY FIRST

0010010010001011

Signed magnitude representation

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

CONVERT TO BINARY FIRST

00000000000000000010010010001011

0000248B

1. Signed magnitude representation

00000000000000000010010010001011

0000248B ANSWER

2. 1s complement representation

00000000000000000010010010001011

0000248B ANSWER
3. 2s complement representation

00000000000000000010010010001011

0000248B ANSWER

b) -16094

00000000000000000011111011011110
3EDE

1. Signed magnitude representation

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

1. Signed magnitude representation

1111111101001110
2. 1s complement representation

1111111101001110

3. 2s complement representation

1111111101001110

c) 70F1

28913

0111000011110001

1. Signed magnitude representation

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

sign exponent mantissa


-1 131 1.00010000000000000000000 (binary)
-1 * 2^(131 - 127) * 1.0625
-1 * 16.0000000 * 1.0625
-17 ANS
c) 40480000

sign exponent mantissa


+1 128 1.10010000000000000000000 (binary)
+1 * 2^(128 - 127) * 1.5625
+1 * 2.00000000 * 1.5625
3.125

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

Sign Exponent Mantissa


Value: -1 20 1.2000000476837158
Encoded as: 1 127 1677722

(bf99999a)16 ANS

b) 275.024

Sign Exponent Mantissa


Value: +1 28 1.074312448501587
Encoded as: 0 135 623378

(43898312)16 ANS

Vous aimerez peut-être aussi