CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Convert unsigned 16bit to signed 32bit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nazoa



Joined: 09 Feb 2007
Posts: 58

View user's profile Send private message

Convert unsigned 16bit to signed 32bit
PostPosted: Fri Sep 10, 2010 9:33 am     Reply with quote

Hello
I am after a way of efficiently converting an unsigned 16 bit integer to a signed 32 bit one. Speed is key in my application. Thanks.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Sep 10, 2010 9:42 am     Reply with quote

Uhhh....

unsigned int16 x;
signed int32 y;

x=0x1234;
y=x;

you could also do:

y=make32(0,x); -- but I'm not sure how it handles signed values. Since I've never tried it.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
nazoa



Joined: 09 Feb 2007
Posts: 58

View user's profile Send private message

PostPosted: Sat Sep 11, 2010 7:48 am     Reply with quote

Thanks for the reply. I was really looking for code that would include the scaling, i.e. mid value of the unsigned variable would translate to zero of the signed variable. Anyway, I found a work around the issue. Thanks again.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Sep 11, 2010 11:33 am     Reply with quote

Ahh,

You didn't say that.

It's usually good to be specific when you have needs that are out of the ordinary.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group