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

12f683 printf

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



Joined: 03 Jun 2005
Posts: 21
Location: TURKEY

View user's profile Send private message Send e-mail MSN Messenger

12f683 printf
PostPosted: Sun Sep 03, 2006 12:31 pm     Reply with quote

hi
after this code timeVar=245
I got this message on SIOW TERMINAL
like" *** timePot=255 timeVar=245 *** "
but I have to get timeVar=(255*11)=2805 why? I do not understand..

Code:


int16 timeVar=0;

timeVar=(timePot*11);
printf("*** timePot=%u timeVar=%lu ***\n\r",timePot,timeVar);
Code:
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Sun Sep 03, 2006 12:54 pm     Reply with quote

Trying casting timePot to an int16 first:

Code:
timeVar = (int16)timePot * 11;
oyhan



Joined: 03 Jun 2005
Posts: 21
Location: TURKEY

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Sun Sep 03, 2006 1:32 pm     Reply with quote

ok thanks for other form like...
(int8 var1)=(int16 var2) / (int8 var3) is necessary or not..
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Sun Sep 03, 2006 1:53 pm     Reply with quote

You have to be careful with CCS and casting - it can be tricky. I've found that mixing int16's and int8's in formulae is a usually a bad idea.

Whenever I have some calcs that mix 8 & 16 bit values, I always write a test program to see if I get the results I expect to see. If not, casting is always the culprit [rather, how CCS handles casting is different from my idea how it should be handled].
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