Floor and Ceiling Functions

The floor and ceiling functions give us the nearest integer up or down.

Example: What is the floor and ceiling of 2.31?

Floor and Ceiling function

The Floor of 2.31 is 2
The Ceiling of 2.31 is 3

Floor and Ceiling of Integers

What if we want the floor or ceiling of a number that is already an integer?

That's easy: no change!

Example: What is the floor and ceiling of 5?

The Floor of 5 is 5
The Ceiling of 5 is 5

Here are some example values for you:

x Floor Ceiling
−1.1 −2 −1
0 0 0
1.01 1 2
2.9 2 3
3 3 3


The symbols for floor and ceiling are like the square brackets [ ] with the top or bottom part missing:

Floor and Ceiling function symbols

But I prefer to use the word form: floor(x) and ceil(x)


How do we give this a formal definition?

Example: How do we define the floor of 2.31?

Well, it has to be an integer ...

... and it has to be less than (or maybe equal to) 2.31, right?

Oh no! There are lots of integers less than 2.31.


So which one do we choose?

Choose the greatest one (which is 2 in this case)

So we get:

The greatest integer that is less than (or equal to) 2.31 is 2

Which leads to our definition:

Floor Function: the greatest integer that is less than or equal to x

Likewise for Ceiling:

Ceiling Function: the least integer that is greater than or equal to x

As A Graph

The Floor Function is this curious "step" function (like an infinite staircase):

Floor function graph

The Floor Function

A solid dot means "including" and an open dot means "not including".

Example: at x=2 we meet:

so the answer is y=2

And this is the Ceiling Function:

Ceiling function graph

The Ceiling Function

The "Int" Function

The "Int" function (short for "integer") is like the "Floor" function, BUT some calculators and computer programs show different results when given negative numbers:

So be careful with this function!

The "Frac" Function

With the Floor Function, we "throw away" the fractional part. That part is called the "frac" or "fractional part" function:

frac(x) = x − floor(x)

It looks like a sawtooth:

Frac function graph

The Frac Function

Example: what is frac(3.65)?

frac(x) = x − floor(x)

So: frac(3.65) = 3.65 − floor(3.65) = 3.65 − 3 = 0.65

Example: what is frac(−3.65)?

frac(x) = x − floor(x)

So: frac(−3.65) = (−3.65) − floor(−3.65) = (−3.65) − (−4) = −3.65 + 4 = 0.35


BUT many calculators and computer programs use frac(x) = x − int(x), and so their result depends on how they calculate int(x):

So be careful using this function with negative values.