CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    12

    Angry Floating point bias question

    question:

    Why is bias like 127 added to floating point numbers' exponets? Why can't the e in the following quote be 2 instead of 127?

    "For example, the number -6.25 in binary is -110.01, or -1 X 1.1001 x 22. This would be represented with s=l,e = 2+127= 10000001, m = [1.] 1001"

    Thanks in advance.

    http://yujiaoguo.blogspot.com
    Last edited by ynkm169; August 18th, 2007 at 04:25 PM.

  2. #2
    Join Date
    Apr 2001
    Location
    Tampa Florida
    Posts
    233

    Re: Floating point bias question

    Hello
    I think I know what you are asking.
    Floating point numbers are stored differently than integers.
    For instance, if you are using 32 bits the first bit is the sign
    2 thru 18 ( for instance cant remember the exact number )
    hold the significant digits (mantissa?) and 19 thru 32 the exponent
    or how far to move the implied floating point to the left or right
    Regards
    "trampling out the vintage"

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Floating point bias question

    See also " IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754)" at http://en.wikipedia.org/wiki/Ieee_floating_point

    Mike

  4. #4
    Join Date
    Aug 2007
    Posts
    12

    Re: Floating point bias question

    Quote Originally Posted by MikeAThon
    See also " IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754)" at http://en.wikipedia.org/wiki/Ieee_floating_point

    Mike
    This web page is really really helpful. particular this part:

    [edit] Exponent biasing
    The exponent is biased by 2e−1−1, see also Excess-N. Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder. To solve this the exponent is biased before being stored, by adjusting its value to put it within an unsigned range suitable for comparison.

    For example, to represent a number which has exponent of 17, exponent is 17 + 2e−1−1. Assuming e = 8, the exponent is equal to 17 + 128 − 1 = 144.


    Thanks

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Floating point bias question

    Glad it helped!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured