View previous topic :: View next topic |
Author |
Message |
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
if and int32 problem |
Posted: Thu Jun 28, 2007 4:20 am |
|
|
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
|
|
Posted: Thu Jun 28, 2007 4:36 am |
|
|
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
|
|
Posted: Thu Jun 28, 2007 4:39 am |
|
|
Thank You for quick sollution. It realy works! |
|
|
|