#3

If you are testing for truth, 0 is "false", and anything other than zero is "true".

Код:
if (0) {
    /*
        this code does not run, since 0 is a "false" value
        ...
    */
}

if (-1) {
    /*
        this code *does* run, since -1 is a "true" value
        ...
    */
}
If you want to do a different test, you need to specify it. To take Pottus's example above, if you have a function that returns a value greater than or equal to 0 on success, and returns -1 on failure:

Код:
if (myFunction() > -1) {
    // this will run if the function is successful
}
It all depends on the context.
Reply


Messages In This Thread
-1 - by BoU3A - 05.11.2014, 02:13
Re: -1 - by Pottus - 05.11.2014, 02:16
Re: -1 - by renegade334 - 05.11.2014, 02:28

Forum Jump:


Users browsing this thread: 1 Guest(s)