Brighton Webs Ltd.
statistical and data services for industry

Home
Index
Feedback

Floor and Ceiling Functions

The floor function takes a floating point number and returns the first integer which is less than or equal to that number.

The ceiling function takes a floating point number and returns the first integer which is greater than equal to that number.

The notation for the floor and ceiling functions is shown below:

Whilst the floor and ceiling functions appear to be similar to rounding, they represent a strict set of rules, whilst rounding functions vary according to application.

Sample values for both functions are shown in the table below:

x floor(x) ceiling(x)
-1.5 -2.0 -1.0
-1.0 -1.0 -1.0
-0.5 -1.0 0.0
0.0 0.0 0.0
0.5 0.0 1.0
1.0 1.0 1.0
1.5 1.0 2.0
 In graphic form:

Spreadsheets

The floor and ceiling functions in Excel and Google Docs work with multiples of a given number, e.g. floor(5.4,2) returns 4, whilst ceiling(5.4,2) return 6.

Programming Languages

These functions are found in most programming languages, e.g. C++ (they were not present in VB6, but were introduced in vb.net).

Page Updated: 06-Feb-2008

 

For more information: info@brighton-webs.co.uk