LOG (Azure Cosmos DB)LOG (Azure Cosmos DB)

适用于: SQL API

返回指定数值表达式的自然对数。Returns the natural logarithm of the specified numeric expression.

语法Syntax

LOG (<numeric_expr> [, <base>])  

参数Arguments

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

basebase
可选的数值参数,用于设置对数的底。Optional numeric argument that sets the base for the logarithm.

返回类型Return types

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

备注Remarks

默认情况下,LOG() 返回自然对数。By default, LOG() returns the natural logarithm. 可以通过使用可选的 base 参数将对数的底更改为其他值。You can change the base of the logarithm to another value by using the optional base parameter.

自然对数是以 e 为底的对数,其中,e 是一个无理常量,约等于 2.718281828。The natural logarithm is the logarithm to the base e, where e is an irrational constant approximately equal to 2.718281828.

数字的指数的自然对数是数字本身:LOG( EXP( n ) ) = n。The natural logarithm of the exponential of a number is the number itself: LOG( EXP( n ) ) = n. 以及数字的自然对数的指数是数字本身:EXP( LOG( n ) ) = n。And the exponential of the natural logarithm of a number is the number itself: EXP( LOG( n ) ) = n.

此系统函数不会使用索引。This system function will not utilize the index.

示例Examples

以下示例声明一个变量并返回指定变量 (10) 的对数值。The following example declares a variable and returns the logarithm value of the specified variable (10).

SELECT LOG(10) AS log  

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

[{log: 2.3025850929940459}]  

以下示例计算某个数字的指数的 LOGThe following example calculates the LOG for the exponent of a number.

SELECT EXP(LOG(10)) AS expLog  

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

[{expLog: 10.000000000000002}]  

后续步骤Next steps