What’s the relative efficiency of integer comparison in java?
==
>=
<=
>
<
Does it depend on the physical architecture?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most hardware instruction sets do these comparisons as two instructions a compare followd by a branch depending on the result of the compare. So for most JVMs on most hardware it makes no difference at all whether its <, <=,= >=, > or !=, its the same two instructions with different flags set.
See this question
Of course it entirely depends on the instruction set and how the JVM authors and their C compiler chooses to use it.