3 ms·
There are no booleans in C, just ints. I think c99 added a 'bool' type, but it's just typedef'd to being an int.
by duaneb 12y ago
There are no booleans in C, just ints. I think c99 added a 'bool' type, but it's just typedef'd to being an int.
- ambrop7 12y agoThat is not correct. In C99, _Bool (and the typedef bool) are special, because when any value is converted to _Bool, the result is 0 or 1 (!!x). Although the standard does not explicitly say that _Bool can only hold anything other than 0 and 1 (only that it is capable of representing these values), this seems to be the case, effectively.
- adsr 12y agoIt's a bit more, the bool type can only hold two values, 0 and 1. (6.3.1.2 Boolean type #1) "When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1."