开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜