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 support@ccsinfo.com

using Make16() on signed variables

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ccs@jeffmann.endjunk.com
Guest







using Make16() on signed variables
PostPosted: Tue Feb 22, 2005 9:39 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 22, 2005 10:21 pm     Reply with quote

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.... Wink
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