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

if and int32 problem

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



Joined: 12 Jun 2007
Posts: 68
Location: Poland, podlaskie district

View user's profile Send private message

if and int32 problem
PostPosted: Thu Jun 28, 2007 4:20 am     Reply with quote

Hello All,

I've got problem with if statment. In short description my code looks like this:
Quote:

main()
{
int32 a=-19999;
if (a>9999)
{
do_something_1();
}
if (a<-9999)
{
do_sometging_2;
}
}



When I start program, do_somenthing_1() function is executed every time.

If I change program like this:
[
Quote:

main()
{
int32 a=19999;
if (a>9999)
{
do_something_1();
}
if (a<-9999)
{
do_sometging_2;
}
}



also do_somenthing_1() function is executed every time.

I suppose that problem is in compareing int32 value, but I don't know how to solve this problem. My device is PIC18f4620.
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Thu Jun 28, 2007 4:36 am     Reply with quote

Hello,

In CCS C All types, except float, by default are unsigned.

Try to declare signed int32 a=-19999;

dro.
_________________
in médio virtus
silelis



Joined: 12 Jun 2007
Posts: 68
Location: Poland, podlaskie district

View user's profile Send private message

PostPosted: Thu Jun 28, 2007 4:39 am     Reply with quote

Thank You for quick sollution. It realy works!
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