Reputation: 374
I have this algorithm set (In my mind) which requires me to cast float to int many times in a loop(about 300 times for each 16 milli seconds) . My question is this:
How costly is process of casting from float to int in java/android and will it cause the game to slow down ?
Is it cheap enough to be implemented by my game? if not, what are the other options to convert decimal to integer?
Edit: Question solved!
Upvotes: 0
Views: 993
Reputation: 13062
A cast from float to int doesn't cost any more than any other assignment statement. It is handled by the hardware. An assignment (depending on the architecture) typically costs a single cycle or one trip through the pipeline (very, very fast). I wouldn't worry about the impact of this conversion on your performance.
Upvotes: 1