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
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!
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.
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.
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 :o
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.
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. :)
Re: Floating point allocation of bits........
Hi,
Quote:
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
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.