I have encountered the following snippet:
pt->aa[!!(ts->flags & MASK)] = -val;
- What does
!!(double exclamation marks/ exclamation points/ two NOT operators) stand for in c? - Doesn’t
(!!NULL) == NULL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
!is negation. So!!is negation of negation. What is important is the fact that the result will be anint.!!xifx == 0is!!0, that is!1, that is0.!!xifx != 0is!!(!0), that is!!1, that is!0, that is1.!!is used commonly if you want to convert any non-zero value to 1 while being certain that 0 remains a 0.And indeed,
!!NULL == NULL, since!!NULL == !!0and!!0 == !1and finally!1 == 0.Consequently, in the short piece of code you cited the array subscript will be either
0if the value of the expression in parenthesis isNULL, and1otherwise.