Ceil

Ceil

Ceil[ expr ] rounds a value up to the nearest integer, or to a given number of decimals.

Usages

Ceil[ expr ]

Ceil[ expr ] returns the smallest integer that is greater than or equal to the value of expr. expr can be any expression with a numerical value.

Example in out
Round 3.1 up. Ceil[ 3.1 ] 4
For negative numbers, rounding up goes towards zero. x := -3.5
r := Ceil[x]
r = -3
An integer stays the same. Ceil[ 4 ] 4
A fraction. Ceil[ 7/2 ] 4
An expression with a numerical value. Ceil[ Sqrt[5]+0.3 ] 3

Ceil[ expr, n ]

Ceil[ expr, n ] rounds up to n decimals. A negative n rounds up to tens, hundreds, and so on.

Example in out
Round up to 2 decimals. Ceil[ 3.14159, 2 ] 3.15
Round up to hundreds. Ceil[ 1234.5, -2 ] 1300

Ceil[ list ]

If the argument is a list, each element is rounded up.

Example in out
Round up each element. Ceil[ {1.2, 2.5, -0.5} ] {2, 3, 0}
Options

OmitTrailingZeroes

If set to False, the result is displayed with exactly n decimals, including zeros at the end. Default: True.

Syntax Example rendered
Ceil[ expr, n, OmitTrailingZeroes=>False ] Ceil[ 3.1, 2, OmitTrailingZeroes=>False ] 3.103.10
Ceil[ 3.1, 2 ] 3.13.1
Details
Invalid input Result
Ceil[ x ] Left unevaluated: the argument must have a numerical value.
Ceil[ 3.1, 1.5 ] Error: The second argument of Ceil must be an integer, but is 1.5
Ceil[ 3.1, 1, 2 ] Error: Ceil must have 1 or 2 arguments, but has 3

See also: Floor, Round, RoundUp