View previous topic :: View next topic |
Author |
Message |
nazoa
Joined: 09 Feb 2007 Posts: 58
|
Convert unsigned 16bit to signed 32bit |
Posted: Fri Sep 10, 2010 9:33 am |
|
|
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
|
|
Posted: Fri Sep 10, 2010 9:42 am |
|
|
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
|
|
Posted: Sat Sep 11, 2010 7:48 am |
|
|
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
|
|
Posted: Sat Sep 11, 2010 11:33 am |
|
|
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 |
|
|
|