in C's logic, do -1 and 1 mean the same thing? i.e FALSE. 0 is the ONLY
value that is interpreted as TRUE right?

cos i have a function (and we'll call it foo() again :) which does
something and returns -1 if there is an error and 0 if it went ok. Now if
in my main() i do this:

/* assume foo() returns 0 for 'it went ok!' */

int ret;
...
        ret = foo();
        if (!ret)
        ...

the stuff in the if loop never gets executed but if i do

        if (ret)
        ...

or

        if (ret == -1)
        ...

it does.

oh! DUUUUH....

ret == -1. !ret or NOT (-1) == 0 or TRUE
ret == -1. !ret AND NOT (-1) == 0 AND TRUE (as well)

sometimes logic can be a bit confusing especially if you !think :)
and i !was thinking (ohhh dear... what is this? 1001 cracker jokes for
programmers?! <- ! a !!... AAGH! who decided to use ! as NOT?!)

[translated literally, using opposite english words...]
sometimes logic can be a bit confusing especially if you (dont think) :)
and i (wasn't) thinking (ohh dear... what is this? 1001 cracker jokes for
(non-programmers) <- (not) a (true)... (whay) who decided to use (not) as
(true?))

yes, that is a load of gibberish, although it does nicely illustrate how
what you _mean_ and what it _actually_ means can be totally different.

Reply via email to