• AdrianoB (unregistered)

    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.

  • xados (unregistered)

    And then there is this Python code (prior to version 3):

    False, True = True, False

Leave a comment on “True Enough”

Log In or post as a guest

Replying to comment #:

« Return to Article