-
In this video will be talking
about the floating point
-
notation, which is designed to
address the problem that we
-
talked about in one of the
previous videos, where we noted
-
that the radix point was jumping
around and I mentioned that it
-
can cause a bit of a confusion
for the computer. Throughout
-
this video I will be talking
about the 8 bit floating point
-
notation which you will find out
very soon. It's a really small
-
system, so it doesn't allow you
to work with huge numbers.
-
However, it's convenient enough
to understand and work with on a
-
paper, and you can just extend
the general rules to any
-
systems. So let's see what is
this floating point notation
-
looks like. Well, the floating
point notation is, 8 bits are
-
broken up into three parts. The
first part is just one single
-
digits telling you what is the
sign of your number. The next 3
-
digits. We called the exponent,
which will tell the computer
-
where to move the decimal point
from here and the last four
-
digits. Called the mantissa. Now
the mantissa is the normalized
-
version of your binary number
into the 0.122 format. We're
-
going to go through it in in
details. Now. The exponent bit
-
in this format is just three
bits, so you can only move your
-
decimal point to three in to the
right or to the left, which
-
straight away as it as you that
you can't really cover great
-
ranges, but it's good enough.
-
And the exponent is expressed as
a 3 bits 2's complement
-
notation. So the sign bit if
we have a positive number be
-
going to use zero if we have a
negative number, we're going to
-
use one. As I said, the exponent
is 3 bits 2's complement.
-
And the mantissa, which is
always 4 bits in this particular
-
number, we're going to have it
-
normalized. So when you
have got a negative
-
number, something like
minus 3 1/2.
-
How are you going to convert
this into an 8 bit floating
-
point notation while step one
-
will be?
-
Identify.
The sign bit.
-
That this is going to be the
easiest one for negative #0 for
-
positive number. Step two will
be is convert into binary.
-
And normalize
-
To get to them on this so.
-
Step
-
3.
Is find the exponent.
-
Which will be something
to do with the month. So
-
how you normalize your
number and express it.
-
As three bits.
-
These complement notation and
the last step.
-
Is just to pull everything
together and put it into the
-
format of the sign followed by
three of the exponent digits and
-
followed by four of the
-
mantissa. OK, it sounds quite a
long and probably a little bit
-
alien in theory, but I think
what we are going to help us if
-
we go through a couple of simple
-
examples. So let's look at minus
-
one. And a quarter.
-
OK sign bit going to
be one because this
-
is a negative number.
-
Not we're going to find the
mantissa for that first. What we
-
need to do? We need to convert 1
1/4 into binary.
-
So. Let's again bring
-
in the. Place values Now this is
the radix point. Here is 124 and
-
the rest of them. The whole
numbers and after comes up half
-
a quarter on 8 etc etc. Now I've
chosen deliberately choosing a
-
simple example so to write 1 1/4
in binary or we need to do is 1.
-
Radix Point followed with 01. So
this is our binary number, but
-
we need to normalize it into the
-
mantissa. So the normalized
the normalized monthly start
-
then will be 0.101. And
remember the amount Esther
-
needs to be 4 bits, so I need
to put an extra 0 into here.
-
Now what happens in this case?
Now I found my mantissa.
-
I found mine on Monday so now,
but I still need my exponent.
-
The exponent the easier way to
think about it is to try to
-
think about the exponent from
the computer's point of view,
-
because once the computer read
-
the. Sign me and the exponent
wait, then the computer will
-
know where to start from and how
many places to move that Radix
-
point. Now from this radix point
here in them from the mantissa
-
to get back to the original
number which remember was minus
-
one and a quarter to get back to
the original number. The
-
computer will need to move one
places into this direction and
-
this is the positive direction.
So I'm moving one place too.
-
The right that's a positive.
It's like multiplying by 10
-
in normal numbers in normal
circumstances, so I'm moving
-
the decimal point by one
places into the positive
-
direction, so my exponent.
-
Will be positive one, but what
does positive one look like in 3
-
bits? This compliment?
-
So remember I've only got 3
bits. It's a positive number, so
-
the 1st digit will be 0 and it's
just positive one, so it's 001.
-
So pulling all these things
together and putting it into the
-
sign, exponent, exponent,
-
mantissa. Format the sign
negative number will be one. The
-
exponent is positive one, so it
will be 001 and the months are
-
now because the computer knows
that the mantissa is designed to
-
be zero point something
something so that zero point. We
-
can always forget and I can just
write down the following 4
-
digits 1010. So this is
equivalent to minus 1 1/4. So
-
this is the 8 bit.
-
Floating point notation 4 -- 1
-
1/4. Now you might spot here
what happens if I had to put.
-
Let's see after normalization, I
end up with five 6 or 7 digits.
-
Well with this Ed bits floating
point, we would have to cut off
-
at the first 4 bits, so we would
have trunking error. Obviously
-
the computer works with bigger
length of digits, therefore that
-
trunking error doesn't come up
as much. So in practical
-
situation when you have to carry
out the calculations, trunking
-
errors do occur.
-
In real situations, when the
computer does it, it's very
-
very minimized.
-
Let's look at another example.
-
Minus two and two 8.
-
Now when I look at this number.
-
Well, I can see here straight
away that I can cancel this one
-
down, and this is actually minus
two end of quarter.
-
OK, so step one.
-
Sign and in this case the sign
will be equal to 1 because I'm
-
talking about a negative number.
-
Step
2
-
convert.
-
And find the mantissa.
-
So 2 1/4.
Let's convert that
-
into binary. Ring in
the place values again, this is
-
your radix .124 half or quarter
and an 8. So for two to build
-
up the whole part we need 1 zero
and the radix point for 1/4. We
-
don't need any half and we use
1/4 so this is our ordinary
-
binary which is equal to 2 1/4.
But remember now we need to
-
normalize it. And the
normalization process goes as.
-
Bring it into the zero point.
-
One and the rest of the digit
would follow, so if I normalize
-
it, what would means I would
need to move this decimal point
-
into the front in here, so I
-
would have. The point moved into
-
here. And then
what would follow
-
now is 0.1001.
-
OK, and remember that this part
will be our mantissa, the one
-
that follows after the point.
-
Then step three is
we need to identify
-
or. Express the
-
exponent. Now remember the
easiest way to think about the
-
exponent is how many places
you would need to move the
-
decimal point. If you were the
computer. So you were reading
-
this number and the origonal
number was one 0.01, so you
-
need to tell the computer via
the exponent that he needs to
-
get to this number from this
number. So what would you need
-
to do in here? You would need
to move the decimal point.
-
Two places into this direction,
and this is the positive
-
direction, so the exponent would
have to be positive too, and the
-
positive two in three bits 2's
complement. Remember positive
-
number is zero and two is 1
zero, so this is our exponent
-
now. And Lastly, pull all these
bits together. The sign bit was
-
one. The three bits of the
exponent is 010, and the four
-
bits of the mantissa.
-
Is 1001, which is
this bit here.
-
So this is
equal to minus
-
two and two
eighths.
-
Now look at the last example
and the locks. That last example
-
will be minus 116th sign bit
which is. First step is again
-
one because it's a negative
number, Step 2.
-
Now I need to convert.
-
And find the mantissa.
-
So place values. I don't have
any whole numbers, so all I'm
-
going to do, I'm going to
express the fractional place
-
values or half a quarter on
-
AIDS. And the 16 and
again because of the way
-
I've chosen this number,
this will be 0.0001.
-
OK that remember that your
monthly site has to be 0.1
-
something. So how can I get from
this number into this format
-
now? The only way I can get
to here is by moving the decimal
-
.123 places so.
-
The exponent, which is
our Step 3.
-
I moved my decimal .3 places.
-
But have I moved it into
positive or negative direction?
-
Let's look at that again. So a
normalized it. But remember that
-
mantis and needs to be 4 bits
long, so I need to put.
-
Three more zeros in here and
now. The computer comes in and
-
you telling the computer that
from this number you want to go
-
back to the original number.
-
OK, so from here to get back
to the origin number of 0.3
-
zeros followed by the one you
have to tell the computer to
-
move the radix point.
-
Into the opposite direction done
before, so this exponent will be
-
negative 3. Now let's see
if we can express negative 3IN.
-
3 bits, two complements.
-
Remember how we did that is
compliment. If it comes to
-
negative numbers, just Express 3
as a 3 bit binary number,
-
positive three and positive
three again using the place
-
values is 124. Remember, we
don't have anything else in
-
here. So it's 011 and to make
it into negative three you need
-
to copy the digits until you
copy the one which is in our
-
case is the very first step and
then invert everything else swap
-
once for zeros and zeros for
once for 01. So this is your
-
negative three in here.
-
So your exponent.
-
He is 101.
-
Put the whole thing
together. Sign bit was one,
-
the exponent is 101 and a
month is soft.
-
Is 1 followed by 3 zero, so
this is the equivalent of minus
-
1 / 16.
-
Not just to recap, with the
computer would actually do in
-
here. The computer would come
and start to read the digits OK
-
with this digit. Here you
telling the computer that he
-
needs to think about a negative
number. With this digit you
-
telling the computer how many
places in what direction he
-
needs to move the radix point
that starts from here and then.
-
That way it will be able to re
normalize the mantissa. Find out
-
what number hides behind this
-
binary code. I hope you not have
a clear idea of how to convert
-
numbers into 8 bits floating
point notation on the following
-
pages you will have some
properties questions and then
-
you will find the answers to
-
these. So these are the
practice questions.
-
And here are the answers.