Results 1 to 9 of 9

Thread: Floating point allocation of bits........

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    Floating point allocation of bits........

    I apologise if this is in the wrong forum.
    Ok guys,

    Right

    i have converted 2659 into floating point format which is:

    Sign ¦ Exponent ¦ Mantissa
    0 ¦ 1100 ¦ 0.101001100011


    0.5 =1
    0.25 =0
    0.125 =1
    0.0625 =0
    0.03125 =0
    0.015625 =1
    0.0078125 =1
    0.00390625 =0
    0.001953125 =0
    0.000976563 =0
    0.000488281 =1
    0.000244141 =1

    so all that added up works out to and then multipled by 2^12 works out to be 2659 which is all dandy.

    However, for the question we're using a 16 bit processor.

    12bits mantissa, 4bits exponent and 1bit for sign = 17bits which is useless for a 16 bit processor.

    Can i have 11 bits for the mantissa instead so i can allocate it for a 16 bit processor?
    But if i allocate 11 bits for the mantissa wouldn't this make the calculation wrong?

    Cheers
    Last edited by flukey2005; Dec 21st, 2005 at 09:21 AM.

  2. #2
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Floating point allocation of bits........

    Can you show how you converted this please, because that may help. I don't know about anyone else, but I've never converted a number like this so anything I post would be a guess at best!

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    Re: Floating point allocation of bits........

    Quote Originally Posted by BobTheBuilder.
    Can you show how you converted this please, because that may help. I don't know about anyone else, but I've never converted a number like this so anything I post would be a guess at best!
    Yeah sure.

    2659 converted into binary is 101001100011.

    Moved the decimal point 12 places so i get.

    0.101001100011

    Exponent is 12.

    so that mantissa multiplied by 10^12 = 2659. Make sense?

    Whats a better way to work it out?

    Cheers.

  4. #4
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Floating point allocation of bits........

    Quote Originally Posted by flukey2005
    Yeah sure.

    2659 converted into binary is 101001100011.

    Moved the decimal point 12 places so i get.

    0.101001100011

    Exponent is 12.

    so that mantissa multiplied by 10^12 = 2659. Make sense?

    Whats a better way to work it out?

    Cheers.
    Eh yeah...still not following. You are saying 0.101001100011 * 10^12 = 2659?

    Because i get 0.101001100011 * 10^12 = 101001100011.

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    Re: Floating point allocation of bits........

    Quote Originally Posted by BobTheBuilder.
    Eh yeah...still not following. You are saying 0.101001100011 * 10^12 = 2659?

    Because i get 0.101001100011 * 10^12 = 101001100011.
    equals 2659 because i converted back into decimal. Sorry i forgot to say

  6. #6
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Floating point allocation of bits........

    Ok sorry for the mass questions but...what's the point then? You converted, shifted the decimal, shifted it back (during the multiplication), the converted back.

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    Re: Floating point allocation of bits........

    Quote Originally Posted by BobTheBuilder.
    Ok sorry for the mass questions but...what's the point then? You converted, shifted the decimal, shifted it back (during the multiplication), the converted back.
    Just making surei its correct.

  8. #8
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Floating point allocation of bits........

    Hi,

    Can i have 11 bits for the mantissa instead so i can allocate it for a 16 bit processor?
    But if i allocate 11 bits for the mantissa wouldn't this make the calculation wrong?

    You just can't do this calculation. To represent a number > 2047 in binary you need 12 digits. Then you need another 4 to represent the xponent in binary and 1 for the sign, which is 17. If you try to use 11 digits in the mantissa, then you can only represent numbers up to 11111111111 = 2047. You still need 4 for the exponent and one for the sign, which is the 16.

    zaza
    Last edited by zaza; Dec 22nd, 2005 at 02:52 PM.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Re: Floating point allocation of bits........

    Usually, there is an excess by 2^(the amount of bits for exponent) - 1 on the exponent. Depends on your cpu. The half precision format should have 5 digits for exponent and 11 for mantissa, but its not standard. If your cpu can't do it, then there are always ways around it although they may waste a lot of cycles.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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