Computer Forums How to convert from two's complement to single precision?

 05-20-2012, 01:08 PM #1 Beta Member   Join Date: May 2012 Location: Czech Republic Posts: 2 How to convert from two's complement to single precision? Hello, Does anybody know how can I convert a number coded in two's complement to single precision? I have 1111111111110011 in two's complement and I need to convert it to single precision. Thank you for your replies. __________________ __________________
 05-20-2012, 09:31 PM #2 Daemon Poster     Join Date: Mar 2012 Location: Taiwan Posts: 1,008 Re: How to convert from two's complement to single precision? Use the first character from the left as sign indicator (in this case, negative). Then convert 111111111110011 as 16384 + 8192 + 4096 ... 16 + 2 + 1, which yields 32755. __________________ __________________ distrACT -- an open community● It helps to ask questions effectively ● Please join Server admins social group if you are into servers
05-21-2012, 02:07 AM   #3
Beta Member

Join Date: May 2012
Location: Czech Republic
Posts: 2
Re: How to convert from two's complement to single precision?

Quote:
 Originally Posted by dale Use the first character from the left as sign indicator (in this case, negative). Then convert 111111111110011 as 16384 + 8192 + 4096 ... 16 + 2 + 1, which yields 32755.
Isn't it 1 bit for sign indicator, 8 bit for exponent and the rest for mantissa?
Like this:
__________________

 05-21-2012, 03:34 AM #4 Daemon Poster     Join Date: Mar 2012 Location: Taiwan Posts: 1,008 Re: How to convert from two's complement to single precision? Ack, I messed up. Let's try again. So you have this number: 1111111111110011 Invert it first because the leftmost digit denotes negative sign: 0000000000001100 Plus 1, i.e.: 0000000000001101 Conversion to decimal yields 13. So the result is -13. __________________ distrACT -- an open community● It helps to ask questions effectively ● Please join Server admins social group if you are into servers
 05-21-2012, 03:39 AM #5 Daemon Poster     Join Date: Mar 2012 Location: Taiwan Posts: 1,008 Re: How to convert from two's complement to single precision? BTW, in response to the image file you posted. It refers to float I believe. Two's complement is all about int. __________________ distrACT -- an open community● It helps to ask questions effectively ● Please join Server admins social group if you are into servers