Table 5-2. Mathematical Functions
Function | Returns | Description | Example |
---|---|---|---|
abs(float8) | float8 | absolute value | abs(-17.4) |
degrees(float8) | float8 | radians to degrees | degrees(0.5) |
exp(float8) | float8 | raise e to the specified exponent | exp(2.0) |
ln(float8) | float8 | natural logarithm | ln(2.0) |
log(float8) | float8 | base 10 logarithm | log(2.0) |
pi() | float8 | fundamental constant | pi() |
pow(float8,float8) | float8 | raise a number to the specified exponent | pow(2.0, 16.0) |
radians(float8) | float8 | degrees to radians | radians(45.0) |
round(float8) | float8 | round to nearest integer | round(42.4) |
sqrt(float8) | float8 | square root | sqrt(2.0) |
cbrt(float8) | float8 | cube root | cbrt(27.0) |
trunc(float8) | float8 | truncate (towards zero) | trunc(42.4) |
float(int) | float8 | convert integer to floating point | float(2) |
float4(int) | float4 | convert integer to floating point | float4(2) |
integer(float) | int | convert floating point to integer | integer(2.0) |
Most of the functions listed for FLOAT8 are also available for type NUMERIC.
Table 5-3. Transcendental Mathematical Functions
Function | Returns | Description | Example |
---|---|---|---|
acos(float8) | float8 | arccosine | acos(10.0) |
asin(float8) | float8 | arcsine | asin(10.0) |
atan(float8) | float8 | arctangent | atan(10.0) |
atan2(float8,float8) | float8 | arctangent | atan3(10.0,20.0) |
cos(float8) | float8 | cosine | cos(0.4) |
cot(float8) | float8 | cotangent | cot(20.0) |
sin(float8) | float8 | sine | cos(0.4) |
tan(float8) | float8 | tangent | tan(0.4) |