Avoid Using Floating-Point
As a rule of thumb, floating-point is about 2x slower than integer on Android-powered devices.
In speed terms, there's no difference between float
and double
on the more modern hardware. Space-wise,double
is 2x larger. As with desktop machines, assuming space isn't an issue, you should prefer double
to float
.
Also, even for integers, some processors have hardware multiply but lack hardware divide. In such cases, integer division and modulus operations are performed in software—something to think about if you're designing a hash table or doing lots of math.
Math
. On versions of Android with a JIT, these are significantly slower than the equivalent
Math
functions, which should be used in preference to these.