- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $ceil (aggregation)
$ceil (aggregation)¶
On this page
Definition¶
-
$ceil¶ New in version 3.2.
Returns the smallest integer greater than or equal to the specified number.
$ceilhas the following syntax:The
<number>expression can be any valid expression as long as it resolves to a number. For more information on expressions, see Expressions.
Behavior¶
If the argument resolves to a value of null or refers to a field that is
missing, $ceil returns null. If the argument resolves to
NaN, $ceil returns NaN.
| Example | Results |
|---|---|
{ $ceil: 1 } |
1 |
{ $ceil: 7.80 } |
8 |
{ $ceil: -2.8 } |
-2 |
Example¶
A collection named samples contains the following documents:
The following example returns both the original value and the ceiling value:
The operation returns the following results: