Page 1 of 1

casting float to int

PostPosted: May 17, 2007 @ 11:23pm
by mm40

PostPosted: May 17, 2007 @ 11:44pm
by Dan East

PostPosted: May 18, 2007 @ 3:57am
by mm40
Yeah thats what I was thinking. I am using floating point math extensively in my game. Fixed point would of course be faster, but I always wait to see if its worth converting after testing.

PostPosted: May 18, 2007 @ 12:25pm
by Dan East
If your game does math real-time and needs to maintain a minimum FPS then fixed point will make a tremendous difference. I can't remember the exact numbers off the top of my head (maybe someone else can pipe in with them), but it was hundreds of cycles required to do a single floating point multiply. In fixed point you've got an integer multiply and a shift - just a couple instructions. So we're talking a factor of hundreds here, not just a few percent difference.

Dan East

PostPosted: May 18, 2007 @ 6:01pm
by Digby

PostPosted: May 18, 2007 @ 6:31pm
by mm40

PostPosted: May 21, 2007 @ 1:50am
by Dan East
Floating point is emulated - the code that performs the actual floating point math is embedded in your app. The libraries produced by Intel and ARM that Digby referred to are simply better optimized - probably hand-coded ASM.

Pocket Quake's performance increased substantially just by rebuilding it with one of those kits, since it still has a decent amout of floating point math. I wasn't the one who did that build, so I can't offer more specifics.

Dan East

PostPosted: May 21, 2007 @ 3:36pm
by mm40