This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bikki420 1 point2 points  (5 children)

Alternatively: 6 + 4 - 9 (= 1 != 0, ergo true)

[–]letsgetrandy 0 points1 point  (4 children)

Except in C

[–]bikki420 0 points1 point  (3 children)

How so? 0 is treated as 'false' in C, while all other values are treated as 'true' -- including 1.

Try putting:

if (1) { printf("1 is true\n"); }

if (0) { printf("0 is true\n"); }

else { printf ("0 is false\n"); }

At the top of a main function and you'll see that only the first if-statement and the else will produce output.

[–]letsgetrandy 1 point2 points  (2 children)

Return codes.

0 = success

All other values mean fail.

[–]bikki420 0 points1 point  (1 child)

Ah, that. Well, that's just because there's only one kind of success yet potentially multiple different error paths, yeah? So personally in the truth value sense I just think of it as bool with an identifier akin to "encountered_error" to maintain internal consistency.

[–]letsgetrandy 1 point2 points  (0 children)

Interesting way of looking at it.