Problem 1:
a)
7
bits
Total number of values that are to
be represented is 128 (0 through 127). Total number of bits used are log2128=
7
b)
9
bits
Total number of values that are to
be represented is 257 (0 through 256). Total number of bits used are log2257=
9 (rounded off to the next integer)
c)
6
bits
Total number of values that are to
be represented is 64 (-32 through 31). Total number of bits used are log264=
6
d)
2
bits
Total number of values that are to
be represented is 3 (i.e., total number of decks). Total number of bits used
are log23= 2(rounded off to next integer)
e)
4
bits
Total number of values that are to
be represented is 0 (1 through 9). Total number of bits used are log29=
4(rounded off to next integer)
f)
5
bits
Total number of values that are to
be represented is 27 (deck1 card 1 through deck3 card 9). Total number of bits
used are log227= 5 (rounded off to next integer)
Problem 2:
a)
The total number of distinct values
that can be encoded in a 32 bit word if all the values are to be positive
integers is 2^32 (from 0 through 4,294,967,295)
b)
The total number of
distinct values that can be encoded will not be affected if negative numbers
are allowed. The total number remains to 2^64.
c)
Binary representation of 12942
The binary representation
is 11 0010 0010 1010
The total number of bits
is 14. To use 16-bit 2’s complement add 2 0’s before this number
Hence the number becomes
0011 0010 0010 1010
Its 1’s complement is 1100 1101 1101 0101
Its 2’s complement is 1100
1101 1101 0110
d)
Binary
representation of 1
The binary representation of 1 is 1
The total number of bits is 14. Now
to make it 16-bit add 15 zero’s ; it becomes
0000 0000 0000 0001
Its 1’s complement is 1111 1111
1111 1110
Its 2’s complement is 1111 1111
1111 1111
e)
Binary
representation of most negative number is
1000 0000 0000 0000
f)
Its
decimal equivalent is -32768
g)
The
negation of -32768 is its 1’s complement that is
0111 1111 1111 1111. Its decimal
equivalent will be 32767
Problem 3:
Hexadecimal representation of
a)
6834ten
Divide 6834 by 16
6834/16 => quotient=427;
remainder=2
427/16 => quotient=26;
remainder=B
26/16 => quotient=1; remainder=A
1/16 => quotient=0; remainder=1
(quotient=0 stop here)
Hexa-decimal representation= 1AB2
hex
b)
-2048ten
By above method 2048 in hexadecimal
form= 800
Now 2048 in binary can be written
is 0000 1000 0000 0000
Its 1’s complement is 1111 0111
1111 1111
Its 2’s complement is 1111 1000
0000 0000
The hexadecimal equivalent of this
number is F800
c)
1001
0110 1010 1101two
Consider 4 bits at a time and write
its equivalent hexadecimal form
96AD
d)
1101
1000 0110 1010 10two
Group all the binary numbers 4 at a
time that is
11 0110 0001 1010 1010
Add two 0’s at most significant
place
0011
0110 0001 1010 1010
Its
binary equivalent is 361AA
e)
-3ten
Represent 3 in binary form
That is 0000 0011
Now its 1’s complement is 1111 1100
Its 2’s complement is 1111 1101
The hexadecimal equivalent of -3 is
FD
Problem 4:
a)
24
ten+31 ten
Operand1= 24ten
Operand2=31ten
Result in decimal form= (24+31)ten= 55ten
Operand1 in binary form = 0001 1000
Operand2 in binary form= 0001 1111
Now adding both the binary numbers we get
0001 1000
0001 1111
0011 0111
So result in binary= 0011 0111
Check it now
0011 0111=
(0*2^7)+(0*2^6)+(1*2^5)+(1*2^4)+(0*2^3)+(1*2^2)+(1*2^1)+(1*2^0)
=0+0+32+16+0+4+2+1
=55
b)
75
ten-23 ten
Operand1= 75
Operand2= -23
Result in decimal form=75-23=52
Operand1 in binary form= 0100 1011
Now consider positive part of
operand2 i.e., 23
23 in binary form is 0001 0111
To represent -23 we need to
consider 2’s complement form
1’s complement= 1110 1000
2’s complement= 1110 1001
Now adding both 75 and -23 we get
0100 1011
1110 1001
(1) 0011
0100
1 is carry. Ignore it.
Result in binary= 0011 0100
c)
13ten-68ten
Operand1=13
Operand2=-68
Result= 13-68=-55
13 in binary= 0000 1101
68 in binary= 0100 0100
-68 in binary can be 2’s complement
of 68 =1011 1100
Now add both binary forms;
0000 1101
1011 1100
1100 1001
Result in binary form= 1100 1001
d)
115ten+65ten
115+65= 180
115 in binary= 0111 0011
65 in binary= 0100 0001
Now add both binary forms;
0111 0011
0100 0001
1011 0100
Result in binary form= 1011 0100
e)
In above solution if we observe
there is 1 at MSB. But in this case 1 is not a sign bit but it is a carry
Problem 5:
a) 82.75
Consider integral part that is 82
82/2 => quotient=41; remainder=0
41/2 => quotient=20; remainder=1
20/2 => quotient=10; remainder=0
10/2 => quotient=5; remainder=0
5/2 => quotient=2; remainder=1
2/2 => quotient=1; remainder=0
1/2 => quotient=0; remainder=1 (stop here as quotient=0)
Now 82= 0101 0010
Consider fractional part that is 0.75
0.75*2=1.5 => whole number is 1
0.5*2=1.0 => whole number is 1
0.0*2=0.0 => stop here
Now .75D=1100 0000
Now 82.75D= 0101 0010.1100 0000
b) -15.01325
Here perform the same steps as above and finally do a 2’s
complement
The answer before two’s complement is
Binary representation of integral part 15= 0000 1111
Binary representation of fractional part .01325D = 0000 0011
Now 2’s complement form of 15= 1111 0001
2’s complement form of .01325D=1111 1100
Hence -15.01325 in binary= (1)1111 0001.1111 1101
c) 0110 1101.0111 0100
In this representation separate the integral and decimal
parts.
Integral part= 0110 1101
Check for the MSB in the integral part. It is zero (0) here.
So the number is positive.
Now the conversion is done by multiplying each binary number
with powers of 2. That is,
0110 1101=
(0*2^7)+(1*2^6)+(1*2^5)+(0*2^4)+(1*2^3)+(1*2^2)+(0*2^1)+(1*2^0)
=0+64+32+0+8+4+0+1
=109
Now the conversion of fractional part is done by multiplying
each binary number with negative powers of 2. That is,
0111 0100=
(0*2^-1)+(1*2^-2)+(1*2^-3)+(1*2^-4)+(0*2^-5)+(1*2^-6)+(0*2^-7)+(0*2^-8)
=0+0.25+0.125+0.0625+0+0.015625+0+0
=0.453125
Hence 0110 1101.0111 0100 in decimal form is 109.453125
d) 1111 1110.0010 0000
Again
separate this number into integral part and fractional part
Integral
part is:
1111
1110. If we observe, this number had MSB 1. So this number turns to be a
negative number. To convert it to positive, we need to follow two’s complement
method to convert this number to decimal.
1111 1110 as 1’s complement= 0000 0001
Its 2’s complement= 1’s complement+1 = 0000 0010
This number in decimal form = -2
Now consider the integral part that is
0010 0000=
(0*2^-1)+(0*2^-2)+(1*2^-3)+(0*2^-4)+(0*2^-5)+(0*2^-6)+(0*2^-7)+(0*2^-8)
=0+0+0.125+0+0+0+0+0=0.125
Now adding both integral and decimal parts we get
-2+0.125 = -1.875
Hence 1111 1110.0010 0000 in decimal form is -1.875
No comments:
Post a Comment