|
|
|
|
|
by shakna
2119 days ago
|
|
>> The value 0 is false, anything else is true. The operators evaluate left to right and stop as soon as the truth or falsity of the expression can be deduced. (Such operators are called "short circuiting") In ANSI C, these are furthermore guaranteed to use 1 to represent true, and not just some random non-zero bit pattern. > Under the assumption that there are no boolean types from earlier, this is not true Actually, I believe _Bool is guaranteed to use 0 for false, and any non-0 value is stored as 1 for true. Arithmetic on _Bool is also guaranteed, based on those values. For example, I believe the standard guarantees: _Bool x = 255;
assert(x == 1);
size_t y = 10 + x;
assert(y == 11);
|
|