[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread Neilz
Right, ok. So in my example, I have Bitmaps being drawn to the Canvas (using an adaptation of SpriteMethodTest which I referred to a few days ago). 1) The Canvas.drawBitmap() method takes two floats as coordinates, so how can I avoid using them? Or if i was to pass 'integer' values, would that

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread Mario Zechner
What you are searching for is called fixed point math. The reason to do this on Android is that many current devices don't have a floating point processing unit. This will change in future devices i'm sure (all second generation devices seem to have an FPU). If you work in Java it does not pay of

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread Mario Zechner
First: what you are in need off is called fixed point math which is implemented by using integers, deciding how many low bits to use for the fractional part of a number and then do some shift magic to do basic math operations. It's an old trick used mainly on devices that do not have an FPU like

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread niko20
I've done numerous testing on this issue when I was coding my audio apps. Using fixed point in the Java code gains NO benefit at all. Using fixed point in NDK native code gives you a MASSIVE speed boost. Like 2 to 4 times faster. -niko On Jun 8, 9:24 am, Mario Zechner badlogicga...@gmail.com

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread Neilz
Interesting, thanks. To go back to my other question, can some one confirm this: When bitmaps get drawn to the screen, is this all wasted precision? Is drawing at 281.01068 any different from drawing at 281.31343? i.e. does it just get drawn at point x=281? -- You received this message

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread ko5tik
On Jun 8, 6:52 pm, Neilz neilhorn...@gmail.com wrote: Interesting, thanks. To go back to my other question, can some one confirm this: When bitmaps get drawn to the screen, is this all wasted precision? Is drawing at 281.01068 any different from drawing at 281.31343? I would say - Yes.

[android-developers] Re: Avoiding float operations in game design

2010-06-08 Thread fadden
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