According to the ECMA standard, this function returns the smallest number value that is not less than the argument and is equal to a mathematical integer. If the argument is already an integer, the argument itself is returned.
Special boundary conditions that affect the results are:
Note that if the value is negative, the magnitude decreases while it increases for positive numbers. The ceil of 25.4 is 26 whereas the ceil of -25.4 is -25.
The result is the input value rounded up to the next higher integer value.
Other reference sources on this function differ as to its functionality. Some indicate that it rounds up to an integer, others that it rounds down. This suggests that some implementations may behave differently since they may use the available documentation to design their interpreter. The ECMA standard is probably the most reliable specification long term since manufacturers will attempt to build ECMA compliance into their implementations as a selling point.
Recent browsers from Microsoft, Netscape and Opera are all compliant with the ECMA standard on this point.
If you are uncertain, you should check the functionality by running some tests. For example, run the test for negative and positive values. Checking a few boundary conditions won't hurt either.
Prev | Home | Next |
Math.atan2() | Up | Math.constructor |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |