Problems(will do in class tomorrow, but try it yourself. Look at the notes):
What is (315)6?
Convert 711 into base 3.
If we used base 16 computers, what range of integers could
we express? What range of numbers using floating points?
What is 1/5 in binary?
Convert (2769)16 into octal.
(315)6 = 3*62+1*6+5 = 3*36+6+5 = 108+11 = 119.
711 in base 3: Divide and recored the remainders:
711 / 3
= 237
Remainder
0
237 / 3
= 79
Remainder
0
79 / 3
= 26
Remainder
1
26 / 3
= 8
Remainder
2
8 / 3
= 2
Remainder
2
2 / 3
= 0
Remainder
2.
So the remainders are 0,0,1,2,2,2 and 711 in base 3 is
222100.
We can check that this is the case:
2*35+2*34+2*33+1*32 = 2*243+2*81+2*27+9
= 486+162+54+9 = 486+225 = 711.
If we use base 16 then:
Using out 16 bits to store number in binary we can represent integers
upto 216, which is about 65000. In fact since we need one bit to
store sign we are limited to 215 or around 32000.
Again we suffer from the two problems we had before, namely
the largest number is too small AND we cannot deal with fractions.
To get round this we again use floating points.
Here we use scientific notation which involves two components. The
mantissa and the exponent. We need to allocate some bits for each. By
doing so we hope be able to deal with a larger set of numbers, at
the expense of not being exact.
I'll pick 11 bits for the mantissa and 5 for the exponent
and compare that to picking 12 and 4 to see which is preferable?
If we have 11 bits for the mantissa then we use 1 for sign
and 10 for the number. This means that our largest number is 210
which is 512. So we only have 3 digits! With 5 bits for our exponent,
one of which must be used for the sign, we have a maximum exponent
of 8. Then our largest number is 512*28 or 5122 < 1000000. This
is larger than the 32000 which we had using the integer format, and
so better. We can deal with fractions since the exponent can be as
small as 2-8 or 1/512ths. BUT we only have 3 significant digits
which is not much at all. At the same time it's not too bad since
when we talk about how far something is we say it's 5 miles away,
not 5.325. Having 3 decimal places is perhaps not too bad, but it's
not great.
If we used 12 for the mantissa and 6 for the exponent, then we'd
have 211 as our largest number, or 1024, which is closer is definitely
3 decimal places. So slightly better, but of course this means we have
one less bit for our exponent so the smallest unit would be 1/256th's.
In away here our choice would depend on what we were doing and whatever
choice we made it would not be as good as 32 bits!
What is 1/5 in binary? We'll work out the first few decimal places.
We have
1/5 = 0.b1b2b3....
To determine b1 we multiply both sides by 2. Then we have
2/5 = b1.b2b3....
Since this is less than 1, b1 = 0 and we have
2/5 = 0.b2b3....
Again we multiply both sides by two to get
4/5 = b2.b3....
So b2 = 0 and
8/5 = b3.b4....
This means that b3 = 1 and
3/5 = 0.b4b5....
So
6/5 = b4.b5...
and b4 = 1 too.
1/5 = 0.b5b6...,
which is back where we started. So b1 = 0, b2 = 0, b3 = 1 and b4 = 1
which repeats:
2/5 = 0.
0011
Convert (2769)16 into octal. This is not that easy, but easy
enough if you don't try to do it in one step. First convert the hex to binary,
then convert it to octal.
(2769)16 = (0010011101101001)2.
Now this has 16 digits, since each hex digit corresponds to 4 binary ones.
Every 3 binary digits then corresponds to one octal one so we need 6 octal ones.
The trick is to pad two 0's to the start!
(000010011101101001)2 = (023551)8
File translated from
TEX
by
TTH,
version 2.70. On 16 Oct 2002, 10:09.