DIV不会与浮动物镜c一起工作(DIV wont work with float objective c)
我正在尝试使用:
float divAm = (float)theAngle%(float)rads;但它的说法是无效的操作数为二进制%
theAngle和rads都是float类型的。
有什么建议吗?
谢谢
I'm trying to use:
float divAm = (float)theAngle%(float)rads;but its saying that Invalid operands to binary %
theAngle and rads are both of type float.
Any suggestions please?
Thanks
最满意答案
模运算符是一个二进制整数运算符 - 它不能与浮点数一起使用。 你应该使用fmod()来代替: -
float fmod(float分子,浮点分母);
它在math.h中定义。 如果你需要的话,还有一个使用双打的版本。
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.
更多推荐
发布评论