abs ( numeric_type )
→ numeric_type
绝对值
abs(-17.4)
→ 17.4
|
cbrt ( double precision )
→ double precision
立方根
cbrt(64.0)
→ 4
|
ceil ( numeric )
→ numeric
ceil ( double precision )
→ double precision
大于等于参数的最接近整数
ceil(42.2)
→ 43
ceil(-42.8)
→ -42
|
ceiling ( numeric )
→ numeric
ceiling ( double precision )
→ double precision
大于等于参数的最接近整数
(与
ceil
相同)
ceiling(95.3)
→ 96
|
degrees ( double precision )
→ double precision
把弧度转换为度
degrees(0.5)
→ 28.64788975654116
|
div ( y numeric,
x numeric )
→ numeric
y/x
的整数商
(向零截断)
div(9, 4)
→ 2
|
erf ( double precision )
→ double precision
误差函数
erf(1.0)
→ 0.8427007929497149
|
erfc ( double precision )
→ double precision
余误差函数
(1 - erf(x),
对于大输入也不会损失精度)
erfc(1.0)
→ 0.15729920705028513
|
exp ( numeric )
→ numeric
exp ( double precision )
→ double precision
指数
(e
的给定次幂)
exp(1.0)
→ 2.7182818284590452
|
factorial ( bigint )
→ numeric
阶乘
factorial(5)
→ 120
|
floor ( numeric )
→ numeric
floor ( double precision )
→ double precision
小于等于参数的最接近整数
floor(42.8)
→ 42
floor(-42.8)
→ -43
|
gamma ( double precision )
→ double precision
Gamma 函数
gamma(0.5)
→ 1.772453850905516
gamma(6)
→ 120
|
gcd ( numeric_type, numeric_type )
→ numeric_type
最大公约数
(能同时整除两个输入且没有余数的最大正数);
如果两个输入都为零则返回
0;
可用于
integer、
bigint
和 numeric
gcd(1071, 462)
→ 21
|
lcm ( numeric_type, numeric_type )
→ numeric_type
最小公倍数
(是两个输入的整数倍的严格最小正数);
如果任一输入为零则返回
0;
可用于
integer、
bigint
和 numeric
lcm(1071, 462)
→ 23562
|
lgamma ( double precision )
→ double precision
伽马函数绝对值的自然对数
lgamma(1000)
→ 5905.220423209181
|
ln ( numeric )
→ numeric
ln ( double precision )
→ double precision
自然对数
ln(2.0)
→ 0.6931471805599453
|
log ( numeric )
→ numeric
log ( double precision )
→ double precision
以 10 为底的对数
log(100)
→ 2
|
log10 ( numeric )
→ numeric
log10 ( double precision )
→ double precision
以 10
为底的对数
(与
log
相同)
log10(1000)
→ 3
|
log ( b numeric,
x numeric )
→ numeric
x
以 b
为底的对数
log(2.0, 64.0)
→ 6.0000000000000000
|
min_scale ( numeric )
→ integer
精确表示所提供的值所需的
最小标度
(小数部分的十进制位数)
min_scale(8.4100)
→ 2
|
mod ( y numeric_type,
x numeric_type )
→ numeric_type
y/x
的余数;
可用于
smallint、
integer、
bigint 和
numeric
mod(9, 4)
→ 1
|
pi ( )
→ double precision
π 的近似值
pi()
→ 3.141592653589793
|
power ( a numeric,
b numeric )
→ numeric
power ( a double precision,
b double precision )
→ double precision
a
的 b
次幂
power(9, 3)
→ 729
|
radians ( double precision )
→ double precision
把度转换为弧度
radians(45.0)
→ 0.7853981633974483
|
round ( numeric )
→ numeric
round ( double precision )
→ double precision
舍入到最接近的整数。
对于 numeric,
平局通过远离零的方向舍入来打破。
对于 double precision,
平局处理行为取决于平台,
但
“舍入到最接近的偶数”
是最常见的规则。
round(42.4)
→ 42
|
round ( v numeric, s integer )
→ numeric
把 v
舍入到
s
个小数位。
平局通过远离零的方向舍入来打破。
round(42.4382, 2)
→ 42.44
round(1234.56, -1)
→ 1230
|
scale ( numeric )
→ integer
参数的标度
(小数部分中的十进制位数)
scale(8.4100)
→ 4
|
sign ( numeric )
→ numeric
sign ( double precision )
→ double precision
参数的符号
(-1、0 或 +1)
sign(-8.4)
→ -1
|
sqrt ( numeric )
→ numeric
sqrt ( double precision )
→ double precision
平方根
sqrt(2)
→ 1.4142135623730951
|
trim_scale ( numeric )
→ numeric
通过移除尾部零来缩小该值的标度
(小数部分的十进制位数)
trim_scale(8.4100)
→ 8.41
|
trunc ( numeric )
→ numeric
trunc ( double precision )
→ double precision
截断为整数
(朝向零)
trunc(42.8)
→ 42
trunc(-42.8)
→ -42
|
trunc ( v numeric, s integer )
→ numeric
把 v
截断到
s
个小数位
trunc(42.4382, 2)
→ 42.43
|
width_bucket ( operand numeric, low numeric, high numeric, count integer )
→ integer
width_bucket ( operand double precision, low double precision, high double precision, count integer )
→ integer
返回 operand
在一个直方图中落入的桶的编号,
该直方图具有
count
个等宽的桶,
覆盖从
low 到
high
的范围。
这些桶的下界是包含的,
上界是不包含的。
对于小于
low
的输入返回
0,
对于大于等于
high
的输入返回
count+1。
如果 low
> high,
行为是镜像反转的,
此时桶
1
是紧邻
low
之下,
包含的边界在上侧。
width_bucket(5.35, 0.024, 10.06, 5)
→ 3
width_bucket(9, 10, 0, 10)
→ 2
|
width_bucket ( operand anycompatible, thresholds anycompatiblearray )
→ integer
在给定一个列出各桶包含下界的数组的情况下,
返回
operand
落入的桶的编号。
对于小于第一个下界的输入返回
0。
operand
和数组元素可以是任何拥有标准比较操作符的类型。
thresholds
数组必须被排序,
最小的在前,
否则会得到意外的结果。
width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])
→ 2
|