DIV不会与浮动物镜c一起工作(DIV wont work with float objective c)

编程入门 行业动态 更新时间:2024-10-28 09:19:23
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.

更多推荐

本文发布于:2023-08-07 22:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:物镜   工作   DIV   wont   objective

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!