View previous topic :: View next topic |
Author |
Message |
ccs@jeffmann.endjunk.com Guest
|
using Make16() on signed variables |
Posted: Tue Feb 22, 2005 9:39 pm |
|
|
I do not understnad if I can use make16() to combine two 8 bit nibbles into a signed 16 bit int16.
the manual explains make16() as doing:
Code: | i16 = (int16)(varhigh&0xff)*0x100+(varlow&0xff) |
so, I am concerned that I cannot do:
[/code]
unsigned int8 byte1, byte2;
signed int16 origional, final;
byte1=make8(origional,1);
byte2=make8(origional,0);
final=make16(byte1, byte2);
[code]
does the signing cause a problem in this case? |
|
|
bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Tue Feb 22, 2005 10:21 pm |
|
|
Since it's simple, I tried it....
The following:
Code: |
origional = -23456;
byte1=make8(origional,1);
byte2=make8(origional,0);
final=make16(byte1, byte2);
|
Results in byte1 = 0xA4 and byte 2 = 0x60, and final = original = 0xa460.
So, with 3.212 on a 452 it works fine....
Bytes is bytes.... |
|
|
|
|
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
|