05.11.2014, 02:28
If you are testing for truth, 0 is "false", and anything other than zero is "true".
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:
It all depends on the context.
Код:
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 (myFunction() > -1) {
// this will run if the function is successful
}

