Ahhh... those were the days.... bitshifting instead of multiplication & dividing.... XORing a value by itself being quicker than setting it to zero (see http://en.wikipedia.org/wiki/Bitwise_operation#XOR if 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 at http://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: [email protected] [mailto:[email protected]] On Behalf Of Jason Proctor Sent: 20 May 2009 23:30 To: [email protected] 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

