PostgreSQL math functions

function return type describe example result
abs(x) absolute value abs(-17.4) 17.4
cbrt(double) cube root cbrt(27.0) 3
ceil(double/numeric) the smallest integer not less than the argument ceil(-42.8) -42
degrees(double) Convert radians to degrees degrees(0.5) 28.6478897565412
exp(double/numeric) natural index exp(1.0) 2.71828182845905
floor(double/numeric) largest integer not greater than the argument floor(-42.8) -43
ln(double/numeric) Natural logarithm ln(2.0) 0.693147180559945
log(double/numeric) Base 10 logarithms log(100.0) 2
log(b numeric,x numeric) numeric the logarithm to the specified base log(2.0, 64.0) 6.0000000000
mod(y, x) take the remainder mod(9,4) 1
pi() double "π" constant pi() 3.14159265358979
power(a double, b double) double Find a to the power of b power(9.0, 3.0) 729
power(a numeric, b numeric) numeric Find a to the power of b power(9.0, 3.0) 729
radians(double) double Convert angles to radians radians(45.0) 0.785398163397448
random() double Random value between 0.0 and 1.0 random()
round(double/numeric) round to the nearest integer round(42.4) 42
round(v numeric, s int) numeric Round to s decimal places round(42.438,2) 42.44
sign(double/numeric) The sign of the parameter (-1,0,+1) sign(-8.4) -1
sqrt(double/numeric) square root sqrt(2.0) 1.4142135623731
trunc(double/numeric) Truncate (towards zero) trunk (42.8) 42
trunk(v numeric, s int) numeric truncates digits to s decimal place trunk(42.438,2) 42.43

Guess you like

Origin blog.csdn.net/yeyaozhifengqi/article/details/130389389