Thread: floating point help!

  1. #1
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73

    floating point help!

    I don't know how to calculate the smallest non-zero denorm.
    okay maybe i know a little.

    so the smallest denorm is this right?
    s exp fraction
    0 [000 0000 0] 000 0000 0000 0000 0000 0001

    and the formula for floating points is this

    1 * 2^-127 * (2^-23) + 1

    how is this = 2^149???

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That plus one should go next to the -23, I think. (I.e, when denormalized, the first bit is in front of the binary point, not behind it.)

  3. #3
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    Hmm,

    According to this:

    http://www.math.byu.edu/~schow/work/...atingPoint.htm

    the smallest possible denorm is represented as:

    0 00000001 00000...

    but i fail to see why they would include a 1 in the exponent.
    but i do see no why they wouldn't put a 1 in the fraction part

    so if we calculate this

    1 * 2 ^ (-126) * ( 0 + 1 [implicit 1] )

    but now i fail to see why 2^-149 = 2^(-126)*2^(-23)

    any suggestions?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by NoobieGecko View Post
    Hmm,

    According to this:

    http://www.math.byu.edu/~schow/work/...atingPoint.htm

    the smallest possible denorm is represented as:

    0 00000001 00000...

    but i fail to see why they would include a 1 in the exponent.
    but i do see no why they wouldn't put a 1 in the fraction part
    That's the smallest normal number.
    so if we calculate this

    1 * 2 ^ (-126) * ( 0 + 1 [implicit 1] )

    but now i fail to see why 2^-149 = 2^(-126)*2^(-23)

    any suggestions?
    Check any junior high or high school mathematics textbook.

  5. #5
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    i know how to add the powers, but of course 2^-149 = 2^(-126)*2^(-23)
    let me fix the question,

    the answer is 2^-149, but how does the above representation lead to that 2^-149??

    or in binary
    how is 0 00000001 0000 ---> 2^-149?

    to get 2^-149 the representation could be

    0 00000000 00000000000000000000001

    without the implicit 1...
    1 * 2^(-127) * 2^(-23) [without the implicit 1] = 2^(-149)

  6. #6
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    oh nevermnd about the 000000...1 000, it is in normal form :O
    but how is the implicit 1 ignored on the second question?

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That's what denormalized means, is that there is no implicit one.
    So instead of 0000000000000000000000000000001 meaning
    1.00000000000000000000001 times 2^(-127), it means
    0.0000000000000000000001 times 2^(-127). Note that there's one less digit -- the first digit of a denormalized mantissa has to take the place of the implicit one that we had before. That is usually achieved by (1) ignoring the 1+ part, since it isn't there any more, and (2) changing the exponent bias to -126 instead of -127 and keeping the binary point in front, so that we would have
    0.0000000000000000000001 times 2^(-126).

    (BTW, if you don't happen to have a textbook with this in it, it's in wikipedia.)

  8. #8
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    thanks, that clears things up now, so every time i have to convert to denormalized i always have to ignore the implicit 1 and shift the decimal point to the right by 1 -- that should do it right.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  2. floating point binary program, need help
    By ph34r me in forum C Programming
    Replies: 4
    Last Post: 11-10-2004, 07:10 AM
  3. floating point question
    By Eric Cheong in forum C Programming
    Replies: 8
    Last Post: 09-10-2004, 10:48 PM
  4. 2 questions about floating point and %
    By ams80 in forum C Programming
    Replies: 2
    Last Post: 08-14-2002, 10:55 AM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM