JDK-6767181 : Crucial mistake in API doc function descriptions
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-11-04
  • Updated: 2011-02-16
  • Resolved: 2008-11-04
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
  Descriptions to the logical pair of functions "java.lang.Math.ceil()" and "java.lang.Math.floor()" are opposite to what it should be. So the description of ceil() describes floor() and vice versa. See also these descriptions in java.math.RoundingMode, where they are correctly placed.

Note: Since errors in rounding operations are often not obviously seen in results, using of the current function descriptions leads to errors, which are extremely difficult to find.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Change places of descriptions. ceil() describes floor() and vice versa.
ACTUAL -
ceil(double a)
 Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

floor(double a)
 Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

URL OF FAULTY DOCUMENTATION :
http://java.sun.com/javase/6/docs/api/

Comments
EVALUATION The specification for floor and ceil are correct as-is. Take ceil: "Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer." Concretely, what should ceil(1.5) be? The answer is clearly 2.0. 2.0 is the *least* integral value *greater than* 1.5. For example, returning some other even larger integral value, like 3.0, would not be correct. Closing as not a bug.
04-11-2008