JosephKK said:
JosephKK said: [...]
Maybe. !! causes an implicit type conversion.
Nothing that ! doesn't already cause, though. .
It is implementation dependent at best. By the rules, !! converts to
BOOL where ! is the bitwise 1's complement. The bit patterns to
implement BOOL types are implementation defined. There are some
differences in the results depending on what the conversions do and
when they occur in the evaluation of the expression.
That is almost entirely wrong.
The unary ! operator yields a result of type int. Its value is 0 if
its scalar argument is unequal to 0; 1 if the argument is equal to 0.
It does not perform a conversion, and it does not yield a result of
type BOOL, _Bool, or bool, even in C99 which defines the latter two
(unless BOOL is an alias for int). Note that the language (including
the standard library) doesn't define anything called BOOL.
!! is simply two applications of the ! operator. !!x yields 0 if x is
equal to 0, 1 of x is unequal to 0. You can more or less think of it
as a conversion, converting any scalar value to its logical 0-or-1
equivalent, but it's really not a conversion, it's just an expression
that yields a value.