While I agree it's good to avoid floating point numbers when doing
integer math, this optimization may or may not have a significant
affect your app's overall FPS, depending on what else it is doing. I
would recommend profiling it, for example with TraceView:
http://developer.android.com/guide/developing/tools/traceview.html#profilepanel


Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.




On May 20, 11:42 pm, Al Sutton <a...@funkyandroid.com> wrote:
> Ahhh... those were the days.... bitshifting instead of multiplication & 
> dividing.... XORing a value by itself being quicker than setting it to zero 
> (seehttp://en.wikipedia.org/wiki/Bitwise_operation#XORif you think I'm making 
> this one up, it was certainly true on a Motorola 68000 embedded system I 
> worked on).
>
> Nowadays this is all normally done automatically by the compiler as an 
> optimisation, so you may not see any benefit doing it explicitly in the code 
> except for making new coders go "wtf is that about?" :).
>
> Al.
>
> ---
>
> * Written an Android App? - List it athttp://andappstore.com/*
>
> ======
> Funky Android Limited is registered in England & Wales with the
> company number  6741909. The registered head office is Kemp House,
> 152-160 City Road, London,  EC1V 2NX, UK.
>
> The views expressed in this email are those of the author and not
> necessarily those of Funky Android Limited, it's associates, or it's
> subsidiaries.
>
>
>
> -----Original Message-----
> From: android-developers@googlegroups.com 
> [mailto:android-develop...@googlegroups.com] On Behalf Of Jason Proctor
> Sent: 20 May 2009 23:30
> To: android-developers@googlegroups.com
> Subject: [android-developers] Speed: Divide by two or multiply by .5? - I 
> wrote a little FPS performance tester to find out.
>
> maybe i'm missing the point here, but dividing by a power of 2 can be
> done very fast by right-shifting. hard to beat that.
>
> >Romain - The idea was to see which is faster to cut an int in half -
> >multiplying by a float (.5) or dividing by two.  I've read that
> >divides are terribly slow but apparently not as bad as floating point
> >multiplications w/ a cast back to an int.
>
> --
> jason.software.particle
--~--~---------~--~----~------------~-------~--~----~
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