ROUND (Azure Cosmos DB)ROUND (Azure Cosmos DB)

适用于: SQL API

返回一个数值,四舍五入到最接近的整数值。Returns a numeric value, rounded to the closest integer value.




是一个数值表达式。Is a numeric expression.

返回类型Return types

返回一个数值表达式。Returns a numeric expression.


执行的四舍五入运算遵循远离零的中点四舍五入。The rounding operation performed follows midpoint rounding away from zero. 如果输入是正好介于两个整数之间的数值表达式,则结果将是离零最近的整数值。If the input is a numeric expression which falls exactly between two integers then the result will be the closest integer value away from zero. 此系统函数将从范围索引中获益。This system function will benefit from a range index.

<numeric_expr><numeric_expr> 已四舍五入Rounded
-6.5000-6.5000 -7-7
-0.5-0.5 -1-1
0.50.5 11
6.50006.5000 77


以下示例将以下正数和负数舍入到最接近的整数。The following example rounds the following positive and negative numbers to the nearest integer.

SELECT ROUND(2.4) AS r1, ROUND(2.6) AS r2, ROUND(2.5) AS r3, ROUND(-2.4) AS r4, ROUND(-2.6) AS r5  

下面是结果集。Here is the result set.

[{r1: 2, r2: 3, r3: 3, r4: -2, r5: -3}]  

后续步骤Next steps