Originally posted by Chitra Jay:
Hello Dan,
Can you tell me how IEEEremainder works.
Just a bit curious to know
Thanks
Chitra,
The following is a question, answer, and remark from an earlier version of my mock exam.
class H {
public static void main (
String[] args) {
double c = Math.IEEEremainder(5,3);
System.out.print(c);
}
}
Prints: -1.0
The Math.IEEEremainder method calculates the remainer using the IEEE 754 standard. The basic algorithm is f1 - f2 X n where n is an integer such that the absolute value of f1 - f2 X n is as small as possible. In this case,
Java selects 2 for the value of n because the absolute value of 5 - 6 is smaller than the absolute value of 5 - 3.