Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Representing (0.5)in IEEE754 format

  • 11-08-2005 01:58PM
    #1
    Registered Users, Registered Users 2 Posts: 641 ✭✭✭


    Ok so this is what my notes tell me..
    • Example: Show the IEEE 754 binary
    representatoin of the number 0.5 in single percision
    • This is equivalent to 1.0 × 2−1 in normalised
    binary scientific notation
    • Thus, the fraction is 00000 . . . 000 (i.e. we
    ignore the “1.” in the significand)
    • The sign is positive, which is 0
    • The exponent is
    −1 + 127 = 12610 = 011111102
    • We can now put it all together
    An Example Conversion
    • Thus the IEEE floating-point formatted number
    for 0.510 is
    00111111000000000000000000000000
    which, formatted differently, is
    0011 1111 0000 0000 0000 0000 0000 0000
    • We can also express this as
    3F00000016
    • Also, 0.5, 1.0 and 1.5 are represented
    in hexadecimal as 3F000000, 3F800000,
    3FC00000, respectively.

    What i can't understand is how you get the fraction if anyone can help it would be greatly appreciated
    Cheers
    Gav


Comments

  • Registered Users, Registered Users 2 Posts: 190 ✭✭pan


    The basic algorithm is:
    to convert fractional part, repeatly multiply the fractional part by 2
    and note the whole part until zero is reached.

    E.g. 5.8125 Fractional decimal number (base 10)
    the integer 5 = 101 in binary (easy part)

    For the fractional part 0.8125
    2*0.8125 = 1.625 keep the 1 and use the 0.625
    2*0.625 = 1.25 keep the 1 and use the 0.25
    2*0.25 = 0.5 keep the 0 and use the 0.5
    2*0.5 = 1.0 keep the 1 and use the 0.0
    2*0.0 = 0.0 keep the 0 and use the 0.0
    etc... for the required number of fractional bits (e.g mantissa should 23 bits long for IEEE 754)

    put it together
    101.1101000000000000... a fractional binary number

    Good luck!

    pan


  • Registered Users, Registered Users 2 Posts: 641 ✭✭✭Dimitri


    Ah, thanks the penny has finally dropped cheers pan much appreciated!


  • Closed Accounts Posts: 79 ✭✭Newb


    I wrote this to demonstrate:
    http://www.tuxpages.com/math/ieee754.shtml


  • Closed Accounts Posts: 79 ✭✭Newb




Advertisement