Thank you for reading this.
What is correct? if(A<=0 && A>100){} or if(A<=0 and A>100){}
I am having trouble understanding boolean operators...
Thank you for reading this.
What is correct? if(A<=0 && A>100){} or if(A<=0 and A>100){}
I am having trouble understanding boolean operators...
C++ has added 'and' as an alias of &&, so either is correct. These are the logical operators they work on the variable as a whole. '&' and 'bitand' are the bitwise operators, they work on individual bits in the variable.
Logical AND is done with the && operator:
Your sample expression seems unlikely since it asks: "If A is negative and A is greater than 100". Clearly, the same variable cannot be negative and greater than 100 at the same instant. While C++ supports "and" most Arduino programmers use the logical AND operator.
They are the same
C++ defines and which is similar to &&
C++ also has and_eq which is the bitwise and, similar to &=
There is a full list of alternative operator representation
&& --> and
&= --> and_eq
& --> bitand
| --> bitor
~ --> compl
! --> not
!= --> not_eq
|| --> or
|= --> or_eq
^ --> xor
^= --> xor_eq
see Alternative operator representations - cppreference.com
There is also on that link the little known digraphs and trigraphs for replacing characters that might not be on some keyboards like replacing { with <% or ??<
Fun to know !
J-M-L:
There is also on that link the little known digraphs and trigraphs for replacing characters that might not be on some keyboards like replacing { with <% or ??<
Sounds like the foundation of another obfuscated C contest.
MorganS:
Sounds like the foundation of another obfuscated C contest.
Yes !!!
thank you everyone