Meaning of !!

On some c code I saw this expression. fillwith = !!fillwith; where fillwidth is a bool.
What's the meaning of double !
Last edited on
It doesn't mean anything special - it's just doing "not" twice.

If fillwidth weren't a bool, it would have the effect of converting its value to a 1 or 0, so simulate a bool. That's a thing you sometimes see in C code. But since you say it's not a bool... I got nuthin'. Maybe some legacy code from an older, pre-C99 standard? I don't think C had a bool type before C99.
Last edited on
It's a cheap (or terse) way of ensuring that fillwith is either 0 or 1.
0 maps to 0.
Everything else maps to 1.

Imagine the expression as
fillwith = (fillwith != 0);
Last edited on
It's an operator in Haskell. Apparently.
No idea what it does.
Thanks for the infos.
If fillwith really is bool then the expression is a no-op.
In haskell it just accesses the nth element in a linked list.
Topic archived. No new replies allowed.