How to extract specific integers from a float iPhone sdk?
I have a formula that outputs a float. What I want to do is to create an int from the first six digits. For example, if the number is 123456789.563324, I want to extract an int value of 456789. How do I do this? I'm using the newest iPhone SDK (XCode 4.4). Thanks for all your help!
I'm not sure of the exact functions for iPhone, but it's pretty standard math. First, you want to make it an integer. The floor function is what you are looking for. Then, you want to compute the modulus of the integer and 1000000. This gets the remainder when the function is divided by 10^6, namely the last 6 digits.
float a = 123456789.563324 int lastdi = floor(a) % 1000000