When explaining the accuracy of floating-point methods, the current java.lang.Math JavaDoc states:
"Informally, with a 1 ulp error bound, when the exact result is a representable number the exact result should be returned; otherwise, either of the two floating-point numbers closest to the exact result may be returned."
This statement is slightly incorrect; instead of the two closest floating-point values it would be more correct to say one of the bracketing floating-point values. The difference between the two definitions occurs when the exact result is slightly greater than a power of two. In that case, the two closest results would be the power of two and the floating-point number next smaller in magnitude than the power of two. The two braketing numbers would be the power of two and the floating-point number next larger in magnitude. This latter definition is the correct (and intended) one.
"Informally, with a 1 ulp error bound, when the exact result is a representable number the exact result should be returned; otherwise, either of the two floating-point numbers closest to the exact result may be returned."
This statement is slightly incorrect; instead of the two closest floating-point values it would be more correct to say one of the bracketing floating-point values. The difference between the two definitions occurs when the exact result is slightly greater than a power of two. In that case, the two closest results would be the power of two and the floating-point number next smaller in magnitude than the power of two. The two braketing numbers would be the power of two and the floating-point number next larger in magnitude. This latter definition is the correct (and intended) one.
- relates to
-
JDK-4929959 Clarify math library ulp accuracy requirements and hypot spec
- Resolved
-
JDK-4455590 JavaDoc: comments for Math, StrictMath don't provide enough detail
- Closed