Go Back   Computer Forums > General Computing > Hardware
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-20-2012, 02:08 PM   #1
Beta Member
 
Join Date: May 2012
Location: Czech Republic
Posts: 2
Default 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.
__________________

oldrich.florian is offline   Reply With Quote
Old 05-20-2012, 10:31 PM   #2
Daemon Poster
 
dale's Avatar
 
Join Date: Mar 2012
Location: Taiwan
Posts: 1,008
Default 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
dale is offline   Reply With Quote
Old 05-21-2012, 03:07 AM   #3
Beta Member
 
Join Date: May 2012
Location: Czech Republic
Posts: 2
Default Re: How to convert from two's complement to single precision?

Quote:
Originally Posted by dale View Post
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:
oldrich.florian is offline   Reply With Quote
Old 05-21-2012, 04:34 AM   #4
Daemon Poster
 
dale's Avatar
 
Join Date: Mar 2012
Location: Taiwan
Posts: 1,008
Default 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
dale is offline   Reply With Quote
Old 05-21-2012, 04:39 AM   #5
Daemon Poster
 
dale's Avatar
 
Join Date: Mar 2012
Location: Taiwan
Posts: 1,008
Default 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
dale is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 04:37 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0