On this page本页内容
$floor
¶New in version 3.2.版本3.2中的新功能。
Returns the largest integer less than or equal to the specified number.返回小于或等于指定数字的最大整数。
$floor
has the following syntax:语法如下所示:
The <number>
expression can be any valid expression as long as it resolves to a number. <number>
表达式可以是任何有效的表达式,只要它解析为一个数字。For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
If the argument resolves to a value of 如果参数解析为null
or refers to a field that is missing, $floor
returns null
. null
值或引用缺少的字段,$floor
返回null
。If the argument resolves to 如果参数解析为NaN
, $floor
returns NaN
.NaN
,$floor
返回NaN
。
{ $floor: 1 } |
1 |
{ $floor: 7.80 } |
7 |
{ $floor: -2.8 } |
-3 |
A collection named 名为samples
contains the following documents:samples
的集合包含以下文档:
The following example returns both the original value and the floor value:以下示例返回原始值和下限值:
The operation returns the following results:操作返回以下结果: