I have heard a teacher drop this once, and it has been bugging me ever since. Let's say we want to check if the integer x
is bigger than or equal to 0. There are two ways to check this:
if (x > -1){
//do stuff
}
and
if (x >= 0){
//do stuff
}
According to this teacher >
would be slightly faster then >=
. In this case it was Java, but according to him this also applied for C, c++ and other languages. Is there any truth to this statement?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…