On Jun 8, 7:18 am, Mario Zechner <badlogicga...@gmail.com> wrote:
> If you work in Java it does not pay of using fixed point math compared
> to using floating point math. For some reasons integer divisions are
> extremely costly and at the end of the day you will need to get the
> non-fractional part of the fixed point number which involves a
> division (or right shift). If you use fixed point math in native code
> via the NDK you might see a bit of a speed up on older devices. If you
> stay in Java land i strongly suggest to staying with floating point
> math.

Two reasons for fixed-point difficulties:

(1) there is no hardware integer divide instruction on ARM.  They
included it in ARMv7-R and ARMv7-M, but that doesn't help for mobile
devices.

(2) You really want a 32x32 -> 64-bit multiply, with a shift to reduce
it back to 32.  There is no such operation in Java, so you have to
convert both args to 64-bit, do a 64x64 -> 64 multiply, and then shift
down.  The instruction overhead kills you.

With the JIT you may find that the balance shifts, and you actually
get a good speed boost with fixed-point on hardware without an FPU.
However, given the way the handset manufacturers seem to be going,
sticking with floating point in your Java code is probably a good
strategy.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to