Computer Forums How to convert from two's complement to single precision?
 User Name Remember Me? Password
 Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes

 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

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules