Specifying the Number of Decimal Places
You can add an optional argument to both the ceil and the floor functions that allows you to specify the number of decimal places for rounding. The syntax for functions with the rounding parameter is as follows:
ceil (parameter_name ornumber, number_of_dec_places)
floor (parameter_name or number, number_of_dec_places)
where number_of_dec_places is an optional value.
Consider the following information about number_of_dec_places:
• It can be represented as a number or as a user-defined parameter. If the parameter value is a real number, it is truncated to an integer value.
• It has a maximum value of 8. If this value is exceeded, the number being rounded (the first argument) is not rounded and the initial value is used.
The next examples show how ceil and floor are used without specifying the number of decimal places:
ceil (10.2) evaluates to 11
floor (–10.2) evaluates to –11
The next examples show the use of ceil and floor when specifying the number of decimal places:
ceil (10.255, 2) evaluates to 10.26
ceil (10.255, 0) evaluates to 11 [This is the same as ceil (10.255)]
floor (10.255, 1) evaluates to 10.2
floor (–10.255, 2) evaluates to –10.26