Functions of Mathematical Operations

Learn about the Mathematical functions supported in Oracle NoSQL Database.

The mathematical functions are used to perform mathematical calculations on the input arguments. Here, the supplied arguments are expressions that resolve to numbers.

You can invoke the mathematical functions from the SELECT/WHERE clauses, and also from other Oracle NoSQL statements where function calls are allowed in the syntax. For example, you can supply mathematical functions as arguments to Using Aggregate Functions.

The following functions are supported in the Oracle NoSQL Database:

Table 12-8 Mathematical functions

Function Description
abs(n) Returns the absolute value of n.
acos(n) Returns the arc cosine of n expressed in radians.
asin(n) Returns the arc sine of n expressed in radians.
atan(n) Returns the arc tangent of n expressed in radians.
atan2(n1,n2) Returns the arc tangent of arguments n1 and n2 expressed in radians.
ceil(n) Returns the smallest integer that is greater than or equal to n.
cos(n) Returns the cosine of an angle n specified in radians.
cot(n) Returns the cotangent of an angle n specified in radians.
degrees(n) Converts n from radians to degrees.
e() Returns the value of the Euler number e.
exp(n) Returns the exponential value of the expression n.
floor(n) Returns the largest integer that is less than or equal to n.
ln(n) Returns the natural logarithmic (base e) value of n.
log(n,b) Returns the logarithmic base b value of n.
log10(n) Returns the logarithmic base 10 value of n.
pi() Returns the value of pi.
power(n2,n1) Returns the value of n2 raised to the power n1.
radians(n) Converts n from degrees to radians.
rand() Returns a pseudo-random number between zero and one.
round(n [,d]) Rounds n to d places to the right of the decimal point.
sign(n) Returns the sign of n.
sin(n) Returns the sine of an angle n specified in radians.
sqrt(n) Returns the square root of n.
tan(n) Returns the tangent of an angle n specified in radians.
trunc(n [,d]) Returns the value of n truncated to d decimal places.

Note:

  • The mathematical function names are case-sensitive.
  • All the mathematical functions expect numeric types (integer, long, float, double, and number) as arguments. These functions return NULL in the following cases. Here, the NULL refers to SQL NULL unless specified otherwise.
    • Any of the arguments resolves to NULL.
    • Any of the arguments is a field in a JSON column whose value is NULL, that is, JSON NULL.
    • Any of the arguments is a field in a JSON column, which does not exist.
    • Any of the arguments is a field in JSON collection, which does not exist.
    • Any of the arguments does not resolve to a numeric type.
  • While using trigonometric functions such as sin(n), cos(n), and so forth, you must specify the input value in radians. You can convert an angle from degrees to radians using the radians(n) function. Similarly, for inverse trigonometric functions like asin(n), acos(n), and so forth, you can convert the resultant radians value to degrees using the degrees(n) function.

To follow along with the examples in the sections, you can create the tables and load data as described in the Additional Examples section.