错误:表达式必须具有整数或枚举类型 [英] Error : Expression must have integral or enum type

查看:2113
本文介绍了错误:表达式必须具有整数或枚举类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vincenty直接公式中,有一个表达式

In a Vincenty Direct Formula, there is an expression

lon2 = (lon1.toRad()+L+3*Math.PI) % (2*Math.PI) - Math.PI; 

/* Where lon2, lon1 is in degrees,L in double, Math.PI(Predefined value for PI) is a constant double */



但是会出现一个错误消息:表达式必须具有整数或枚举类型",并且还表明%的左侧具有双精度型,而右侧具有恒定的双精度型.但这就是公式.我该如何摆脱呢?



But there is an error that says: "Expression must have integral or enum type" and also shows that the left hand side of % has a double and right hand side has a constant double. But that is the formula. How do I get rid of this?

推荐答案

那么?双倍%双倍是Double,不是吗?因此,如果期望lon2的整数,除非将其显式转换为整数,否则它将抱怨.
So? A Double % a Double gives a Double, doesn''t it? So if it expects an integer for lon2 it will complain unless you cast it to an integer explicitly.


模运算符%不能与浮点操作数一起使用.使用fmod()函数计算浮点值的余数.
The modulo operator % can''t be used with floating point operands. Use the fmod() function to calculate the remainder for floating point values.


这篇关于错误:表达式必须具有整数或枚举类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆