- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I wanted to comment on this line:
Prior to the C99 standard, there wasn't a standardized version of boolean values
In C, if you do this:
int result = (2 == 2);
result will be 1. The result of the comparison operators [==, !=, <, >, <=, >=] and logical operators [&&, ||, !] is only 0 or 1. So, in some sense, true is defined as 1. I agree that the if and while statements will treat any non-zero value as "true", but the compiler did give you only one value for "true" ==> 1. Lacking a true boolean type, if and while had to do something with the int values they tested that were not 0 or 1. There is plenty of room for debate on what they should have done instead of what they did, but we're stuck with it now.
Admin
And then there is this Python code (prior to version 3):
False, True = True, False