Binary 5 - Floating Point Range versus Precision

Поділитися
Вставка
  • Опубліковано 11 вер 2024
  • This is the fifth in a series of videos about the binary number system which is fundamental to the operation of a digital electronic computer. In particular, this video elaborates on the representation of real numbers using floating point binary notation. It explains how the relative allocation of bits between the mantissa and the exponent in a fixed size register can impact on the range and precision of the values that can be represented. It also draws a distinction between precision and accuracy, and points out some of the limitations of floating point binary. The video also mentions the importance of an awareness among programmers of how floating point binary works, including a demonstration of the kind of error that can occur when using single and double data types in a simple Visual Basic.NET program.

КОМЕНТАРІ • 33

  • @TheFlyguy31
    @TheFlyguy31 6 років тому +10

    Watching your video's has taught me to understand binary on an intuitive level.

  • @arupduttabappy3284
    @arupduttabappy3284 3 роки тому +6

    You know the art of teaching,, loving this playlist so much

  • @jakobalbrechtsen925
    @jakobalbrechtsen925 2 роки тому +3

    Thanks for making these videos (and the series) available; they are of great help with good and varied use of examples with to-the-point explanations. I'll be recommending it to others.

  • @DominicCurtis
    @DominicCurtis Рік тому +4

    I love computer science :)

  • @bakedbeaaanz
    @bakedbeaaanz 2 роки тому +3

    why cant we represent 7.5 with 4 bit mantissa and 4 bit exponent?
    wouldn't 1111 0011 give you 7.5?

    • @ComputerScienceLessons
      @ComputerScienceLessons  2 роки тому +1

      This would be -1 (see below). Your mantissa starts with a 1 which means you have a negative number. You should assume the mantissa and the exponent are both in two's complement.
      1111 0011
      = 1.111 X 2^3
      = 1111.0
      =-1

    • @bakedbeaaanz
      @bakedbeaaanz 2 роки тому +1

      @@ComputerScienceLessons so does that mean if we didn't use two's complement, we would be able to represent 7.5?

  • @MarvinStroud3
    @MarvinStroud3 5 років тому +1

    So that explains why Open Office Calc displays tiny discepencies from time to time. Thanks.

  • @Sawyer0823
    @Sawyer0823 2 роки тому

    II am a little confused about accuracy and precision in IEEE754 & AI.
    I would like to knoe if Mantissan & exponent have direct relationship with result's accuracy and precision.
    Like, in IEEE754, will it be more precise with more Mantissa? and more accuracy with more exponent?
    I know that if i want to do HPC, FP64 is better than FP32 and FP16. And INT8 is more suitable for AI inference.
    I am kind of stuck here and very confused about the concept of accuracy and precision.

  • @NoName-tj8dm
    @NoName-tj8dm Рік тому

    Thanks for the great video.
    I have calculated the largest and smallest value in 4 bit register having 2 bit for mantissa and 2 bit for exponent
    For largest value
    Exponent is 01
    Mantissa is 010.0
    Mantissa in decimal is 2
    For smallest value
    Exponent is 01
    Mantissa is 10.0
    Mantissa in decimal is -2
    Can you please confirm if above is correct or not ?

    • @ComputerScienceLessons
      @ComputerScienceLessons  Рік тому

      Using the format described in this video, with a 4 bit register, and assuming the mantissa and the exponent are both in two's complement...
      The largest number, in binary, will be
      0101
      The mantissa is 01 and the exponent is 01
      The two bit mantissa is positive, because it starts with 0.
      Imagine a binary point to the right of the leftmost bit of the mantissa, so the mantissa is 0.1
      The exponent is also positive, namely denary 1.
      We therefore have 0.1 x 2^1
      When we float the point one place to the right we get 1.0 in 'pure' (fixed point) binary.
      which is denary +1
      The smallest number, in binary, will be
      1010
      The mantissa is 10 and the exponent is 10
      The two bit mantissa is negative, because it starts with 1.
      Imagine a binary point to the right of the leftmost bit of the mantissa, so the mantissa is 1.0
      The exponent is also negative, namely denary -2.
      We therefore have 1.0 x 2^-2
      When we float the point two places to the right we get 0.01 in 'pure' (fixed point) binary.
      Now, you have to bear in mind that the original mantissa was negative, so the most significant bit in 0.01 has a negative place value. In this case -0.25
      So the smallest denay number is -0.25

    • @NoName-tj8dm
      @NoName-tj8dm Рік тому +1

      @@ComputerScienceLessons Dear Sir,
      First of all, Thanks for your all effort and response. Only Because of you I have begun to understood the floating point representation of decimal in binary.
      Here I believe , For the smallest , Binary Should be 1001
      hence the mantissa is 10 and exponent is 01
      So, I have 1.0 x 2^1
      and 1.0 * 2^1 = 10 = -2
      and hence smallest denary is -2.
      Please correct me if I am wrong.

    • @ComputerScienceLessons
      @ComputerScienceLessons  Рік тому +1

      You are quite correct. 1001, namely, -2 is the smallest. Embarrassingly, I was wong. :_KD

  • @vojar3692
    @vojar3692 5 років тому +1

    So, how anything really works if small errors keep accumulating, and we have to use floating point numbers :/? it seems like an important limit in programming calculations
    If we imagine computer clock (that uses float) then eventually it will show us wrong time...

    • @milestailsprower4555
      @milestailsprower4555 3 роки тому

      Because .1 can't represent in binary
      .0(0011)
      Max value of double = 179.7969313 uncentillion

    • @EricFontaineJazz
      @EricFontaineJazz 2 роки тому

      If avoiding the small accumulation errors is crucial, then the designer may decide to use fixed point representation and to use a data structure that represents a number as a fraction. For instance, when dealing with money (such as a banking database), I believe it is more common to treat decimals as just a plain integer with a fixed decimal point. And in the computer clock, it would be likely that internally the timestamps are represented as an integer as a count (or as multiples) of the computer's clock cycles.

  • @mixxamm
    @mixxamm 5 років тому +3

    2:17 I'm pretty sure single precision has a 23-bit mantissa, not 24-bit. Great video nonetheless.

    • @oTakisApoTinAchaia
      @oTakisApoTinAchaia 5 років тому +6

      Alright, according to the IEEE 754 standard, in a 32-bit system you have:
      - 1 bit for the sign of the number
      - 8 bits for the exponent and
      - 23 bits for the mantissa.
      So he's probably including the sign to the mantissa referring to it as a whole, in terms of the 2's complement representation. That doesn't make quite a differnce in the way we approach the topic in this video, but in some applications it is vital to separate them.

    • @pkus
      @pkus 2 роки тому

      I think 24 bit here he meant with sign bit

  • @thenomad9963
    @thenomad9963 Рік тому +1

    damn this guy is good

  • @justcurious1940
    @justcurious1940 Рік тому

    using c++ gives more accurate result it does output 100 for the loop part
    is it up to the processor or the programming language ?
    double x = 0 ;
    x = 0+0.1 ;
    std::cout

    • @justcurious1940
      @justcurious1940 Рік тому

      great serie by the way i'm watching it all

    • @ComputerScienceLessons
      @ComputerScienceLessons  Рік тому

      You welcome. I'm working on a C# course at the moment. I look forward to your comments. :)KD

  • @sirpiesmasher8482
    @sirpiesmasher8482 7 років тому

    Yes mate, sick vid. Look 4wad 4 more