DIV wont work with float objective c
I'm trying to use:
float divAm = (float)theAngle%(float)rads;
but its saying that Invalid operan开发者_StackOverflowds to binary %
theAngle and rads are both of type float.
Any suggestions please?
Thanks
The modulus operator is a binary integer operator - it cannot be used with floats. You should use fmod() instead:-
float fmod( float numerator, float denominator );
It's defined in math.h. There is also a version using doubles if you need that.
精彩评论