3 ms·
0 == true is also used in C error return values, where nonzero means "false" as in "did not succeed." So it's not without precedent. It's not a terrible idea.
by api 10y ago
0 == true is also used in C error return values, where nonzero means "false" as in "did not succeed." So it's not without precedent.
It's not a terrible idea. In most types of computing there's often only one way for something to be true but N ways for it to be false.
- jacquesm 10y agoThis is really not the case. The C language and the standard library are distinct things. C originally did not define any values at all for booleans (true / false), but later implementations did and even in the oldest C compilers (0 == 0) would evaluate to '1', which caused the most repeated lines of C preprocessor input ever written: #define TRUE 1 #define FALSE 0 Guarded by some #ifdefs if your compiler supported that. Some standard library functions return nonzero on error (which can be < 0 or > 0), zero on 'success' which is not the same as true, and others (annoyingly) return 1 on 'success' or 'true' (such as the isalpha function/macro).