|
-
Dec 21st, 2005, 09:17 AM
#1
Thread Starter
Member
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.
-
Dec 21st, 2005, 11:41 AM
#2
Addicted Member
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!
-
Dec 21st, 2005, 11:45 AM
#3
Thread Starter
Member
Re: Floating point allocation of bits........
 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.
-
Dec 21st, 2005, 12:02 PM
#4
Addicted Member
Re: Floating point allocation of bits........
 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.
-
Dec 21st, 2005, 02:41 PM
#5
Thread Starter
Member
Re: Floating point allocation of bits........
 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
-
Dec 21st, 2005, 03:25 PM
#6
Addicted Member
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.
-
Dec 21st, 2005, 05:02 PM
#7
Thread Starter
Member
Re: Floating point allocation of bits........
 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.
-
Dec 22nd, 2005, 11:11 AM
#8
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.
-
Dec 24th, 2005, 05:40 AM
#9
transcendental analytic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|