In mathematics, there are two elementary special functions called ceiling() and floor() which allow us to round up or down, respectively, to the nearest whole number. These functions exist natively in PHP, but not in ASP. They are handy in situations where you want to force a number like 15.8 to round down to 15, but the round() function rounds it up to 16 according to the standard rules for rounding.

#### ASP

`function floor(x)`

`dim temp`

`temp = round(x)`

`if temp > x then`

`temp = temp - 1`

`end if`

`floor = temp`

`end function`

`function ceil(x)`

`dim temp`

`temp = round(x)`

`if temp < x then`

`temp = temp + 1`

`end if`

`ceil = temp`

`end function`

## No comments:

Post a Comment