Java IEEEremainder(double,double)未为类型Math定义
我试图在GWT中使用Java IEEEremainder(double,double)未为类型Math定义,java,gwt,Java,Gwt,我试图在GWT中使用java.lang.Math.IEEEremainder(双f1,双f2)。但我得到了以下例外 [错误]第1119行:IEEEremainder(double,double)方法是 数学类型的未定义 我试图执行以下代码:angle=Math.IEEEremainder(angle,360.0) 如何在GWT中解决此问题?。如果它不能解决问题,那么实现与数学相同功能的替代方法是什么。IEEEremainder此方法。根据GWT中不支持此功能 因此,如果您确实需要它,并且无法解决
java.lang.Math.IEEEremainder(双f1,双f2)
。但我得到了以下例外
[错误]第1119行:IEEEremainder(double,double)方法是
数学类型的未定义
我试图执行以下代码:angle=Math.IEEEremainder(angle,360.0)代码>
如何在GWT中解决此问题?。如果它不能解决问题,那么实现与数学相同功能的替代方法是什么。IEEEremainder
此方法。根据GWT中不支持此功能
因此,如果您确实需要它,并且无法解决它,那么您需要自己实现它
如果我理解正确的话,你是想把角度限制在360度。
您可以通过以下代码实现这一点:
/**
* Normalize a degree value.
* @param d value
* @return 0<=value<=360
*/
public static double normalizeDegrees(double d)
{
while (d < 0)
{
d += 360;
}
while (d > 360)
{
d -= 360;
}
return d;
}
/**
*标准化度值。
*@param d值
*@return 0=value=360
*/
公共静态双规范化表(双d)
{
而(d<0)
{
d+=360;
}
而(d>360)
{
d-=360;
}
返回d;
}
如果您得到的是正数,您甚至可以跳过上面的,而-块。如果您确实需要在GWT中使用该方法,请按如下方式实现:
/**
* Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The remainder value is
* mathematically equal to <code>f1 - f2</code> × <i>n</i>, where <i>n</i> is the
* mathematical integer closest to the exact mathematical value of the quotient {@code f1/f2}, and if two
* mathematical integers are equally close to {@code f1/f2}, then <i>n</i> is the integer that is even. If the
* remainder is zero, its sign is the same as the sign of the first argument. Special cases:
* <ul>
* <li>If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or
* negative zero, then the result is NaN.
* <li>If the first argument is finite and the second argument is infinite, then the result is the same as the first
* argument.
* </ul>
* @param f1 the dividend.
* @param f2 the divisor.
* @return the remainder when {@code f1} is divided by {@code f2}.
*/
public static double IEEEremainder(double f1, double f2)
{
double div = Math.round(f1 / f2);
return f1 - (div * f2);
}
(我将此添加为新注释以显示语法突出显示)。请发布您的代码?@thegauravmahawar请检查我的更新问题。实际上我想使用IEEEremainder方法,但由于JRE仿真,我无法使用它。那么,在GWT中有没有其他方法可以实现相同的功能呢?