View previous topic :: View next topic |
Author |
Message |
scanan
Joined: 13 Aug 2004 Posts: 58 Location: Turkey
|
LESS than <0 |
Posted: Wed Sep 01, 2004 5:05 am |
|
|
why
if(x<0) don't work |
|
|
alexbilo
Joined: 01 Jun 2004 Posts: 39 Location: Trois-Rivières
|
|
Posted: Wed Sep 01, 2004 5:47 am |
|
|
Quote: |
why
if(x<0) don't work
|
Actually, it does... I think that posting a little more details about your code would help...
What make you think that it doesn't work? _________________ Alex |
|
|
Ttelmah Guest
|
Re: LESS than <0 |
Posted: Wed Sep 01, 2004 6:38 am |
|
|
scanan wrote: | why
if(x<0) don't work |
It won't work, if 'x' is an _unsigned_ integer. Remember the default 'int' type is unsigned...
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Sep 01, 2004 8:25 am |
|
|
Try:
signed int8 x;
that should make 'x' be valid from -128 to 128. If you omit the 'signed' portion it makes 'x' valid from 0 to 255. That one bit me when I first started using CCS.
Ronald |
|
|
bdavis
Joined: 31 May 2004 Posts: 86 Location: Colorado Springs, CO
|
|
Posted: Wed Sep 01, 2004 10:31 pm |
|
|
How about -127 to 128 instead of -128 to 128? I'm sure that's what you probably meant anyway |
|
|
Guest
|
|
Posted: Thu Sep 02, 2004 2:25 am |
|
|
And how about -128 to 127? 0b01111111 is 127.I'm sure that's what you probably meant anyway |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Sep 02, 2004 8:33 am |
|
|
Ok, Ok. Got some smart ones out there.
I guess I'll just walk over to the bit bucket and toss one in the garbage to make it and even -127. |
|
|
|