< Return to Video

https:/.../emt111080p-1.mp4

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

English subtitles

Revisions