KnowledgeBoat Logo

Computer Applications

Distinguish between Math.ceil() and Math.floor()

Java Math Lib Methods

205 Likes

Answer

Math.ceil( )Math.floor( )
Returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integerReturns the largest double value that is less than or equal to the argument and is equal to a mathematical integer.
double a = Math.ceil(65.5);
In this example, a will be assigned the value of 66.0 as it is the smallest integer greater than 65.5.
double b = Math.floor(65.5);
In this example, b will be assigned the value of 65.0 as it is the largest integer smaller than 65.5.

Answered By

129 Likes


Related Questions