Why is 2 * (i * i) faster than 2 * i * i in Java?
There is a slight difference in the ordering of the bytecode. 2 * (i * i): iconst_2 iload0 iload0 imul imul iadd vs 2 * i * i: iconst_2 iload0 imul iload0 imul iadd At first sight this should not make a difference; if anything the second version is more optimal since it uses one … Read more