Numeric Functions

Table 47. Numeric Functions

Function

Description

abs

Returns the absolute value of num_value.

Value type: Same as num_value

Syntax: dst_var = abs(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • dst_var = decimal, float, or integer variable.

Example: let#dabsvar = abs(#dvar)

acos

Returns the arccosine of num_value in the range of 0 to p radians. The value of num_value must be between -1 and 1.

Value type: float

Syntax: dst_var = acos(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #facosvar = acos(#fvar)

asin

Returns the arcsine of num_value in the range of -p/2 to p/2 radians. The value of num_value must be between -1 and 1.

Value type: float

Syntax: dst_var = asin(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fasinvar = asin(#fvar)

atan

Returns the arctangent of num_value in the range of -p/2 to p/2 radians. The value of num_value must be between -1 and 1.

Value type: float

Syntax: dst_var = atan(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fatanvar = atan(#fvar)

ceil

Returns a value representing the smallest integer that is greater than or equal to num_value.

Value type: Same as num_value.

Syntax: dst_var = ceil(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • dst_var = decimal, float, or integer variable.

Example: let #fceilvar = ceil(#fvar)

cos

Returns the cosine of num_value.

Value type: float

Syntax: dst_var = cos(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fcosvar = cos(#fvar)

cosh

Returns the hyperbolic cosine of num_value. This function returns a float value.

Syntax: dst_var = cosh(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fcoshvar = cosh(#fvar)

deg

Returns a value expressed in degrees of num_value which is expressed in radians.

Value type: float

Syntax: dst_var = deg(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fdegvar = deg(#fvar)

e10

Returns the value of 10 raised to num_value.

Value type: float

Syntax: dst_var = e10(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fe10var = e10(#fvar)

exp

Returns the value of e raised to num_value.

Value type: float

Syntax: dst_var = exp(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fexpvar = exp(#fvar)

floor

Returns a value representing the largest integer that is less than or equal to num_value.

Value type: Same as num_value

Syntax: dst_var = floor(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • dst_var = decimal, float, or integer variable.

Example: let #ffloorvar = floor(#fvar)

hex

Returns a string, in the form of 0x?, which is the hexadecimal representation of the argument

Syntax: dst_var = hex(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to an integer.

  • dst_var = string variable.

Example: let $hexvar = hex(#fvar)

log

Returns the natural logarithm of num_value.

Value type: float

Syntax: dst_var = log(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #flogvar = log(#fvar)

log10

Returns the base-10 logarithm of num_value.

Value type: float

Syntax: dst_var = log10(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #flog10var = log10(#fvar)

mod

Returns the fractional remainder, f, of x_value/ y_value such that x_value = i * y_value + f, where i is an integer, f has the same sign as x_value, and the absolute value of f is less than the absolute value of y_value. The arguments are promoted to the type of the greatest precision and the function returns a value of that type.

Syntax: dst_var = mod(x_value, y_value)

  • x_value = decimal, float, or integer literal, column, variable, or expression.

  • y_value = decimal, float, or integer literal, column, variable, or expression.

  • dst_var = decimal, float, or integer variable.

Example: let #fmodvar = mod(#fxvar, #fyvar)

power

Returns the value of x_value raised to the power of y_value.

Value type: float

Syntax: dst_var = power(x_value, y_value)

  • x_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • y_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fpowervar = power(#fxvar, #fyvar)

rad

Returns a value expressed in radians of num_value which is expressed in degrees.

Value type: float

Syntax: dst_var = rad(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • place_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fradvar = rad(#fvar)

round

Returns a value that is num_value rounded to place_value digits after the decimal separator.

Value type: Same as num_value

Syntax: dst_var = round(num_value, place_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • place_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #frndvar = round(#fvar, #fplace)

sign

Returns a -1, 0, or +1 depending on the sign of num_value.

Value type: float

Syntax: dst_var = sign(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • dst_var = decimal, float, or integer variable.

Example: let #fsignvar = sign(#fvar)

sin

Returns the sine of num_value.

Value type: float

Syntax: dst_var = sin(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fsinvar = sin(#fvar)

sinh

Returns the hyperbolic sine of num_value.

Value type: float

Syntax: dst_var = sinh(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fsinhvar = sinh(#fvar)

sqrt

Returns the square root of num_value..

Value type: float

Syntax: dst_var = sqrt(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #fsqrtvar = sqrt(#fvar)

tan

Returns the tangent of num_value.

Value type: float

Syntax: dst_var = tan(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #ftanvar = tan(#fvar)

tanh

Returns the hyperbolic tangent of num_value.

Value type: float

Syntax: dst_var = tanh(num_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #ftanhvar = tanh(#fvar)

trunc

Returns a value that is num_value truncated to place_value digits after the decimal separator.

Value type: Same as num_value

Syntax: dst_var = trunc(num_value, place_value)

  • num_value = decimal, float, or integer literal, column, variable, or expression.

  • place_value = decimal, float, or integer literal, column, variable, or expression. The value is always converted to float.

  • dst_var = decimal, float, or integer variable.

Example: let #ftruncvar = trunc(#fvar, #fplace)

The transcendental functions sin, cos, tan, sinh, cosh, and tanh take their arguments in radians. The functions asin, acos, and atan return radian values. To convert from radians to degrees or degrees to radians, use the rad or deg functions as follows:

let #x = sin(rad(45)) ! Sine of 45 degrees.
let #y = deg(asin(#x))! Convert back to degrees.

If arguments or intermediate results passed to a numeric function are invalid for that function, Production Reporting halts with an error message.

For example, passing a negative number to the sqrt function causes an error. Use the cond function described in Table 52 to prevent division by zero or other invalid function or operator argument values.