Mathematical Functions

Table 5-2. Mathematical Functions

FunctionReturnsDescriptionExample
abs(float8)float8absolute valueabs(-17.4)
exp(float8)float8raise e to the specified exponentexp(2.0)
ln(float8)float8natural logarithmln(2.0)
log(float8)float8base 10 logarithmlog(2.0)
pi()float8fundamental constantpi()
pow(float8,float8)float8raise a number to the specified exponentpow(2.0, 16.0)
round(float8)float8round to nearest integerround(42.4)
sqrt(float8)float8square rootsqrt(2.0)
cbrt(float8)float8cube rootcbrt(27.0)
trunc(float8)float8truncate (towards zero)trunc(42.4)
float(int)float8convert integer to floating pointfloat(2)
float4(int)float4convert integer to floating pointfloat4(2)
integer(float)intconvert floating point to integerinteger(2.0)

Most of the functions listed for FLOAT8 are also available for type NUMERIC.

Table 5-3. Transcendental Mathematical Functions

FunctionReturnsDescriptionExample
acos(float8)float8arccosineacos(10.0)
asin(float8)float8arcsineasin(10.0)
atan(float8)float8arctangentatan(10.0)
atan2(float8,float8)float8arctangentatan3(10.0,20.0)
cos(float8)float8cosinecos(0.4)
cot(float8)float8cotangentcot(20.0)
sin(float8)float8sinecos(0.4)
tan(float8)float8tangenttan(0.4)