开发者

DIV wont work with float objective c

开发者 https://www.devze.com 2023-01-16 18:53 出处:网络
I\'m trying to use: float divAm = (float)theAngle%(float)rads; but its saying that Invalid operan开发者_StackOverflowds to binary %

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

精彩评论

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