log()

返回以10为底的对数的函数

log() 是一个系统函数,用于返回指定值的以10为底的对数。

log() 添加于 PostgreSQL 6.5

用法

log ( numeric ) → numeric
log ( double precision ) → double precision

提供的值必须大于 0

请注意,log10() 作为 SQL 标准的等效函数存在,与 log() 相同。

变更历史

示例

log() 的基本用法示例

postgres=# SELECT log(2);
        log         
--------------------
 0.3010299956639812
(1 row)

无法计算零或负数的对数

postgres=# SELECT log(0);
ERROR:  cannot take logarithm of zero

postgres=# SELECT log(-1);
ERROR:  cannot take logarithm of a negative number

分类

系统函数

另请参阅

log10(), ln()

反馈

如果您对“log()”有任何意见、建议或更正,请在此处 提交