I've seen !! in some piece of code and I can't find it in the reference.
What !! as in "digitalWrite(dataPin, !!(val & (1 << i)));" means?
Thank you.
I've seen !! in some piece of code and I can't find it in the reference.
What !! as in "digitalWrite(dataPin, !!(val & (1 << i)));" means?
Thank you.
Not not
If x is zero, not not x is zero.
If x is non zero, not not x is 1
It's a hack to get an explicit conversion to boolean for an object that can't cast to boolean on it's own.
It's a lot easier to overload the "!" operator than it is the "bool" operator. The latter can cause some type conversions to happen that you don't expect.
Thank you all.
Delta_G:
It's a hack to get an explicit conversion to boolean for an object that can't cast to boolean on it's own.It's a lot easier to overload the "!" operator than it is the "bool" operator. The latter can cause some type conversions to happen that you don't expect.
That at least is the first explanation that I've read of why one would use !!.
Thank you