+ 2
a=5,b=2 a!=!!b What does the operation do?
3 Answers
+ 5
In "C", a non zero integer is "true"(so a is true and b is also true) and the "!" operator is the NOT operator. Your second line reads as; a is NOT equal to (NOT NOT b) which is equivalent to; a is NOT equal to b (5 is not equal to 1) and the result is "true" (i.e one(1)).
In case you are confused, let me explain further:
b was originally 2 (which is true)
!b becomes false (i.e 0)
!!b becomes true (i.e 1)
a != !!b means 5 is not equal to 1....
and that statement is true (1)
+ 3
Yes Calvin Thomas, that is a concise way of explaining it