2 ms·
If x is any nonzero value [example: 2], !!x is 1. Any nonzero expression is true, and 0 is false. But the result of !, or ==, ||, or any of those other boolea
by asveikau 7y ago
If x is any nonzero value [example: 2], !!x is 1.
Any nonzero expression is true, and 0 is false. But the result of !, or ==, ||, or any of those other boolean operators is 1 for true.
Recall relatedly that C didn't have a bool type until the 1999 standard, which introduced <stdbool.h>. C++ had it earlier, but for a long time the C way to store a boolean expression into a variable might have been int, or some nonstandard typedef. This is why so many libraries and frameworks in the C world define their own boolean type.