Why There is a Bias 127 in Exponent in IEEE 754 Standard Single Precision

Поделиться
HTML-код
  • Опубликовано: 19 сен 2024
  • This video will discuss why there is bias of 127 in ieee 754 standard.
    For more details
    www.ias.ac.in/a...

Комментарии • 11

  • @Lisa-kk6go
    @Lisa-kk6go 6 лет назад +5

    Doesn't we get range from -128 to 127 if we use signed and get range from -127 to 128 if we use unsigned and the biased exponent?

    • @alta-sh
      @alta-sh 6 лет назад +19

      Ok so when you're using a Sign bit to represent negative numbers, you are correct. You would get -128 to 127 within an 8bit register. However, a signed bit system of representing negative numbers can't be used when trying to represent an exponent in floating point binary because there is a flaw in the signed bit system when using it for this, and that is, as explained in the video, you can have positive and negative zero exponent within a signed bit system. So to counter this, we use what is called the bias system. Now, using the bias system, it's impossible to represent positive and negative zero. Let me give you an example:
      With an 8 bit register, we use a 127 bias. So, if I want to represent the exponent number 2. I would represent that as the number 129, because when the bias (127) is subtracted from it, I get the number 2, which is the correct exponent I'm trying to represent.
      So, what If I want to represent the exponent 0? Well, I would simply represent the number 127 in the 8 bit register. Notice how there can only be one zero? not a positive or negative? This is why we use the bias system, normally in conjunction with a sign bit. However the sign bit is used to represent whether or not the mantissa is positive or negative and the bias is used to represent whether or not the exponent is positive or negative.
      Now onto your question of shouldn't it be -128 - 127 like the sign bit?
      Ok so, let's say the number you're trying to represent in an 8bit register with a 127 bias is -128, how would that be done?
      Well, if we fill the entire 8 bit register with zero's, then subtract the bias from it, we are left with the exponent representation of -127, right? That is the smallest number we can represent with a 127 bias. The largest number would be if we filled the register with all 1's, which would be the number 255, however after subtracting the bias we get 128. This is the largest number we can represent with a 127 bias.
      So, can't we just increase the bias in order to represent smaller numbers? Let's use a 128 bias? Sure we can do this, but you'll start to lose the largest number you can represent.
      Let me give you an example again:
      If the exponent we want to register in an 8 bit register with a 128 bias this time, is -128, then we would fill the register with all zero's, because 0 - 128 = -128. Great :) But what is the largest number we can represent? Well let's fill the entire register with 1's and find out. Ok so an 8 bit register filled with 1's is 255, then subtract the 128 bias and we are representing the exponent 127.
      As you can see this is similar to what the sign bit is able to represent, but it is by tradition to use a 127 bias in an 8bit register, not a 128 bias. As you increase the bias, you can represent smaller negative exponents and small positive exponents as well. Imagine if you have a 255 bias in an 8bit register, then you would not be able to represent a single positive exponent, and the smallest exponent you would be able to represent would be -255...
      I hope this explains it a bit better and you now have a clearer understanding of the difference between the bias and the sign bit.

  • @tharindujayasankha5151
    @tharindujayasankha5151 3 года назад

    perfect explaning

  • @deepakbhardwaj3141
    @deepakbhardwaj3141 6 лет назад

    Well explained......

  • @IamUSER369
    @IamUSER369 6 лет назад +3

    -128

  • @Agreedtodisagree
    @Agreedtodisagree 4 года назад +2

    I think you should remove this video and upload a corrected one. The range would be from -127 to 128 in an 8-bit exp representation. It may mislead some people as there is a major error in the video.

    • @HowTomakeitdone
      @HowTomakeitdone  4 года назад

      Hi thanks for your comment.
      In the video, I have used one's complement representation of negative number for explanation purpose which has the range from -127 to 127 (having two representation for zero: positive and negative). That was just for explanation and I am sorry if it's giving wrong impression about the range.
      You are also right regarding the range being from -127 to 128.
      Thanks for your comment.

    • @TheGoodOldDays-IsNow
      @TheGoodOldDays-IsNow 4 года назад +5

      @@HowTomakeitdone Sorry, but you are not correct. In 2's compliment there is only one zero and that is 00000000, using an 8-bit value. The binary value 10000000 represents -128 (negative 128) in 2's compliment, it is not -0 (negative zero). Also you say here and in your reply one year ago to Lusha Li that you are using 1's compliment, which is also not correct. Maybe you intended to use 1's compliment, but at 2:02 in you video, you explicitly say that it will be stored in 2's compliment.
      Since two's compliment only has a single zero value - one of the reasons we use it for signed integers - it could also be used to implement floating point exponents. In older machines it sometimes was - I'm an old engineer and used to work with them. Because of this, your video doesn't really explain why we use a bias of 127 instead of 2's compliment.
      One of the real reasons for Excess127 is to allow one extra value of the positive exponent for very large numbers (128 instead of the 127 we get with 2's compliment) and we correspondingly reduce the possible values for negative exponents by one (from -128 to -127) for very small numbers. In other words, we shift the bias in favour of very large numbers rather than very small ones, because in most scientific applications, large numbers occur more often than numbers smaller than 10 to the power of -38 (which is approximately the equivalent of 2 to the power of -127).
      I also think @Lusha Li was not asking for more detail, she was trying to point you in the right direction, as was @lloЯTRoll. What they both said was correct!
      Do yourself a favour and follow @Salman Hussain's suggestion. Delete this video because it causes confusion and is not correct. Feel free to make a new one with the correct information.

    • @TheGoodOldDays-IsNow
      @TheGoodOldDays-IsNow 4 года назад

      As a follow up: the reason I gave for using Excess 127 - allowing larger numbers to be stored - isn't really the main reason, but that would take more than a minute or two to explain.

    • @fariahasan3965
      @fariahasan3965 4 года назад

      @@TheGoodOldDays-IsNow would you explain the main reason of using Excess 127 ?

  • @kaushiknits0307
    @kaushiknits0307 5 лет назад +1

    there is a subtle mistake in this video