Thank for your quick reply, Adam! You wrote: > Well, to my knowledge, CCS C is an Ansi compiler. If so, it should follow the > ansi C spec. We hope ;-) > > IIRC, when doing a comparison between two variables which are not explicitly > cast, they are both converted to the 'next higher' variable, which would be a > signed long. If that was the case, your comparison would be fine. > > Since that is not the case, than one of my two assumptions are incorrect (either > CCS is not ansi in this respect, or ANSI does not require a specific method of > casting variables when doing compare operations). > Maybe CCS converts them both to signed INTs. In that case -6 (= 250) would really be less than 0. ????? > At any rate, since you know that your signed int cannot possible ever go above > 250, why even make the comparison? I'm assuming it's just to demonstrate the > problem. Is there a reason why you can't define them both as the same type of > variable? > Later on in the program these variable change values, and the statement is supposed to be true at that point. The way they are calculated requires the signed int, but it seems to be causing more trouble than it's worth. I would sure like to understand *WHY* this doesn't work instead of just fixing it without learning anything! I am going to try a version with them the same type of variables (both INTS). If 250 is still greater than zero then I will go throw my scope in the lake. (just kidding) > -Adam > > Lawrence Lile wrote: > > > > In CCS C, I've got the following statements: > > > > int SlopeSetpt = 250; > > Signed int Slope = 0; > > > > . > > . > > . > > . > > > > if (slope >= SlopeSetpt){ > > > > do some code... > > > > } > > > > I keep having trouble that the IF statement is true, and executes even > > though 0 should be less than 250. > > > > How would CCS C evaluate this statement given that the two variables are > > different types? > > > > -- Lawrence Lile > > Sr. Project Engineer > > Salton inc. Toastmaster Div. > > 573-446-5661 Voice > > 573-446-5676 Fax > > > > -- > > http://www.piclist.com hint: The PICList is archived three different > > ways. See http://www.piclist.com/#archives for details. > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > > > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.