Hi I have a question regarding the use of Boolean operators, mainly "or" in an if then statement.
I am writing something where I was previously using the statement-
if (wvform1 == 1 || wvform1 == 4 || wvform1 == 5 || wvform1 == 6 || wvform1 == 7) dblSpd1 = spd1 * 2;
Which is pretty long so I thought I'd simplify it to performing the action if wvform1 is not 2 or 3-
if (wvform1 != 2 || wvform1 != 3) dblSpd1 = spd1 * 2;
As I currently understand, this statment "translates" to "if wvform1 is not equal 2 or if wvform1 is not equal to 3" and these two statements produce equivalent results. Let me know if I've misunderstood something though.
My question is, would I be able to use the following statement as a revision to the smaller statement above?-
if (wvform1 != 2 || 3) dblSpd1 = spd1 * 2;
As I understand, this translates to "if wvform1 is not equal to 2 or 3", maybe a slightly different logical question than the previous.
I have not found answers to this on my own. The code runs as I expect but I am curios if there's something about this logic that is not apparent or if I should avoid this type of language in the future.