|
|
Title | Compare the speeds of different calculations |
Keywords | calculation, multiplication, division, speed, time, performance |
Categories | Algorithms, Tips and Tricks |
|
|
This program performs a series of calculations to compare the speed of division, multiplication, and integer division using Single, Double, Integer, and Long data types.
Dividing integers and longs using \ is faster than using /. Multiplying by 0.5 is faster than dividing by 2.
On my computer, the Long data type is faster than the Integer type. Single and Double are even faster. This probably depends on your CPU.
Note that the differences are small so you should not change the way you perform calculations if it makes the code less clear.
|
|
|
|
|
|