I reading this code, and have this line
switch (!!up + !!left) {
what is !!
operator ? two logical NOT ?
C NOT Logical Operator is used to inverse the result of a boolean value or an expression. ! is the symbol used for NOT Logical Operator in C programming. C NOT Operator takes only one boolean value as operand and returns the result of NOT operation.
Logical OR (||) operator in C Logical OR is denoted by double pipe characters (||), it is used to check the combinations of more than one conditions; it is a binary operator – which requires two operands.
The result of a logical OR ( || operator in C) is true if EITHER of its inputs is true. Similarly logical AND ( && operator in C) is true if BOTH of its inputs are true.
yes, it's two nots.
!!a
is 1
if a
is non-zero and 0
if a
is 0
You can think of !!
as clamping, as it were, to {0,1}
. I personally find the usage a bad attempt to appear fancy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With