If x is an integer, the unary C operator !x is defined as
!x = 1 if x is 0 !x = 0 if x is not 0
Like the bit operators, bang acts on integers with an integer result, but unlike the bit operators, it uses the whole integer value, not each separate bit.
What are the following expressions where x is an integer value ( 4 bytes or equivalently, 8 hex digits)
!!x | (if x is 0) | |
!!x | (if x is not 0) | |
x ^ x | ||
!(x ^ x) |