Mathematical functions

Mathematical functions return values commonly needed for operations on mathematical data.

Each function also accepts arguments that can be implicitly converted to the specified type. For example, functions that accept approximate numeric types also accept integer types. Adaptive Server converts the argument to the desired type. See “Conversion error handling”.

Adaptive Server provides error traps to handle domain or range errors. Use the arithabort and arithignore functions to specify how domain errors are handled.

Table 16-1 displays examples using the floor, ceiling, and round mathematical functions.

Table 16-1: Examples of mathematical functions

Statement

Result

  • select floor(123)

  • select floor(123.45)

  • select floor(1.2345E2)

  • select floor(-123.45)

  • select floor(-1.2345E2)

  • select floor($123.45)

123 123.000000 123.000000 -124.000000 -124.000000 123.00

  • select ceiling(123.45)

  • select ceiling(-123.45)

  • select ceiling(1.2345E2)

  • select ceiling(-1.2345E2)

  • select ceiling($123.45)

124.000000 -123.000000 124.000000 -123.000000 124.00

  • select round(123.4545, 2)

  • select round(123.45, -2)

  • select round(1.2345E2, 2)

  • select round(1.2345E2, -2)

123.4500 100.00 123.450000 100.000000