I need to extract ‘thousands’ from an integer (e.g. 1345 -> 1; 24378 -> 24) and since my application is going to do this a lot, I need to do this efficiently.
Of course, division by 1000 is always an option, but division is an expensive operation so I’m looking for something more efficient.
The target platform is Android and as far as I know most Android platforms today do not have a math co-processor, so the most preferred way would be to do this by bit-wise manipulations, though I can’t figure out how to do that and if its possible at all…
A math coprocessor will be a great assistance with floating point operations but just about every modern CPU will have efficient integer division.
Seriously, just do the divide operation, it will almost certainly be the best option. While bit shifting is good for division by powers of two (like 1024), it’s not so good otherwise.