Math is Fun
Bookmark Add to favorites
link Link here
Math is Fun HomeHome





Top-rated teacher Web sites rated by teacher usage
Edunet site of the week January 2001
Maths Is Fun is ICRA Registered

Copyright © 2009
MathsIsFun.com

Floor and Ceiling Functions

The floor and ceiling functions give you 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 you 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

Symbols

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

Floor and Ceiling function

Definitions

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?

  • 2 is less than 2.31 ...
  • but 1 is also less than 2.31,
  • and so is 0, and -1, -2, -3, etc.

There are lots of integers less than 2.31.

So which one do we choose? Choose the largest one, which is 2

The largest 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

The Floor Function

(a solid dot means "including"
an open dot means "not including")

If it looks confusing, just imagine you are at some x-value (say x=1.5), and see what y-value you get ... does it make sense now?

Example: at x=2 we meet an open dot at y=1 (so it does not include x=2), and a solid dot at y=2 (which does include x=2) so the answer is y=2

And this is the Ceiling Function:

Ceiling function

The Ceiling Function

The "Frac" Function

When you use the Floor Function, you "throw away" the fractional part. That part is called the "frac" function:

frac(x) = x - floor(x)

It looks like a sawtooth:

Frac function

Example: what is frac(3.65)?

Answer: frac(x) = x - floor(x) = 3.65 - 3 = 0.65

Example: what is frac(-3.65)?

Answer: frac(x) = x - floor(x) = (-3.65) - (-4) = -3.65+4 = 0.35

(Note that it isn't 0.65)