Skip to main content

Rounding Operations

Ceiling, flooring and rounding are mathematical functions that help with converting floating point numbers to the nearest whole numbers.

  1. ceiling - Gives always the next largest whole number. Example: ceil(2.3)=3ceil(2.3) = 3, ceil(−2.3)=−2ceil(-2.3) = -2
  2. flooring - Gives always the next smallest whole number. Example: floor(2.3)=2floor(2.3) = 2, floor(−2.3)=−3floor(-2.3) = -3
  3. rounding - Rounds to the nearest whole number. Example: round(2.3)=2round(2.3) = 2, round(2.5)=3round(2.5) = 3, round(−2.3)=−2round(-2.3) = -2, round(−2.5)=−2round(-2.5) = -2
using in programming

These functions are useful in programming problems. In Java, the math class already provides all three methods.