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

signed char and signed long

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



Joined: 26 Apr 2009
Posts: 9

View user's profile Send private message

signed char and signed long
PostPosted: Tue Apr 28, 2009 5:36 pm     Reply with quote

Hello,

Does the CCS compiler support a signed char subtraction from a signed long?

Code:

signed long x;
signed char y;
x=989;
y=-45;
x=x+y;
x=944


I do not have a way to verify this but I need it to know how to do the code.

Thanks.
--Luis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 5:49 pm     Reply with quote

Quote:
I do not have a way to verify this

Do you have the CCS compiler and MPLAB ? If so, you have the power
to make a test program and run it in the MPLAB simulator. Configure
the simulator to display printf() text in the Output Window.
Instructions on how to do this:
http://www.ccsinfo.com/forum/viewtopic.php?t=23408&start=1

Here's the output of the following program:
Quote:
944


Here is the test program:
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
void main()
{
signed long x;
signed char y;

x=989;
y=-45;
x=x+y;
printf("%ld", x);

while(1);
}
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 5:51 pm     Reply with quote

Standard C rules say it should promote Y to a long and then do the math. I would be astonished if CCS could not handle this automatically.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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