This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi TI expert
I use the controller is DSP TMS320F280049.
when I use CCS10.1.0,I find that the result of if(a||b == 1) is not equal to if(a == 1 || b == 1).
By the way , it sometimes cannot perform an if judgment
Best regards,
Thomas
Thomas,
What results are you observing? Did the previous statement work in any previous CCS instance? Based on my understanding of order of precedence, equality (==) has higher precedence than logical OR (||). Therefore (a||b ==1) is actually checking if b==1 then deciding if a exists or b equals 1. This is different than the second expression which is checking the value of a equals 1 or b equals 1.
See https://northstar-www.dartmouth.edu/doc/idl/html_6.2/Operator_Precedence.html for more information on operator precedence in C.
Regards,
Ozino
Hi Ozino
sorry, There are some problems with what I described yesterday. when I type if(V_f||I_f) ,No matter what the situation, it will enter this if.
Best regards,
Thomas
Thomas,
The conditional statement is checking the value of the variable. It it supposed to return, a boolean value only. ie. TRUE
or FALSE
. So in your statement, you are basically checking if there is a value declared for either V_f OR l_f. If either one of these is defined, it will enter the condition.
Double check if this is what you intend to verify. If so, it appears that prior to the if statement, one or both of those variables are declared and have an assigned value.
stackoverflow.com/.../if-statement-that-has-in-condition-only-a-variable
Regards,
Ozino