mardi 3 novembre 2015

Is there a quantifiable benefit for comparing to zero if negative numbers are not a factor?

Assuming that negative numbers are not a factor; is there a clear, quantifiable benefit (such as a performance difference) for comparing zero using the greater than or equal to operators?

For example, compare the two IF statements below:

if (x > 0) {
   functionOne();
} else {
   functionTwo();
}

if (x == 0) {
   functionTwo();
} else {
   functionOne();
}

Aucun commentaire:

Enregistrer un commentaire