More remainder
Patrick Tullmann
tullmann at cs.utah.edu
Wed Sep 30 10:38:43 PDT 1998
Here's a simple example that demonstrates the floating-point remainder
problem.
-Pat
/*
* Correct output:
* 8.0 % 3.0 = 2.0
* IEEERemainder(8.0, 3.0) = -1.0
*/
class Bug
{
public static void main(String[] args)
{
double a = 8;
double b = 3;
double r = a%b;
System.out.println(a+ " % " +b+ " = " +r);
r = java.lang.Math.IEEEremainder(a,b);
System.out.println("IEEERemainder(" +a+ ", " +b+ ") = " +r);
}
}
More information about the kaffe
mailing list