Mathematical (system words)
Mathematical system words perform operations such as absolute value, cosine, natural log, and rounding. These words operate on items (and return values to items) of the following kinds:
- Numeric items; these are of type BIGINT, BIN, DECIMAL, INT, NUM, NUMC, PACF, SMALLINT
- Items of type HEX:
- An item of type HEX (length 8) is assumed to be a single precision, 4-byte floating-point number that is native to the run-time environment
- An item of type HEX (length 16) is assumed to be a double precision, 8-byte floating-point number that is native to the run-time environment
The mathematical system functions can raise exception conditions; but a try ... onException ... end block is necessary if you wish sysVar.errorCode to receive the returned code.
The mathematical functions return the following values for sysVar.errorCode:
- 8: The argument is not in a valid range
- 12: The intermediate or final result cannot be represented as a double-precision floating point number or with the precision of the result parameter
- 16: A function exception has occurred
The mathematical system words are listed in the next table.
System function/Invocation Description mathLib.abs result = mathLib.abs (numericItem)Returns absolute value of numericItem mathLib.acos result = mathLib.acos (numericItem)Returns arccosine of numericItem mathLib.asin result = mathLib.asin (numericItem)Returns arcsine of numericItem mathLib.atan result = mathLib.atan (numericItem)Returns arctangent of numericItem mathLib.atan2 result = mathLib.atan2 (y, x)Computes the principal value of the arc tangent of y/x, using the signs of both arguments to determine the quadrant of the return value mathLib.ceiling result = mathLib.ceiling (numericItem)Returns smallest integer not less than numericItem mathLib.compareNum result = mathLib.compareNum (numericItem1, numericItem2)Returns a result (-1, 0, or 1) that indicates whether numericItem1 is less than, equal to, or greater than numericItem2 mathLib.cos result = mathLib.cos (numericItem)Returns cosine of numericItem mathLib.cosh result = mathLib.cosh (numericItem)Returns hyperbolic cosine of numericItem mathLib.exp result = mathLib.exp (numericItem)Returns exponential value of numericItem mathLib.floatingAssign result = mathLib.floatingAssign (numericItem)Returns numericItem as a double-precision floating-point number mathLib.floatingDifference result = mathLib.floatingDifference (numericItem1, numericItem2)Returns the difference between numericItem1 and numericItem2 mathLib.floatingMod result = mathLib.floatingMod (numericItem1, numericItem2)Calculates the floating point remainder of numericItem1 divided by numericItem2, with the result having the same sign as numericItem1 mathLib.floatingProduct result = mathLib.floatingProduct (numericItem1, numericItem2)Returns product of numericItem1 and numericItem2 mathLib.floatingQuotient result = mathLib.floatingQuotient (numericItem1, numericItem2)Returns quotient of numericItem1 divided by numericItem2 mathLib.floatingSum result = mathLib.floatingSum (numericItem1, numericItem2)Returns sum of numericItem1 and numericItem2 mathLib.floor result = mathLib.floor (numericItem)Returns the largest integer not greater than numericItem mathLib.frexp result = mathLib.frexp (numericItem, integer)Splits a number into a normalized fraction in the range of .5 to 1 (which is the returned value) and a power of 2 (which is returned in integer mathLib.ldexp result = mathLib.ldexp (numericItem, integer)Returns numericItem multiplied by 2 to the power of integer mathLib.log result = mathLib.log (numericItem)Returns the natural logarithm of numericItem mathLib.log10 result = mathLib.log10 (numericItem)Returns the base 10 logarithm of numericItem mathLib.maximum result = mathLib.maximum (numericItem1, numericItem2)Returns the greater of numericItem1 and numericItem2 mathLib.minimum result = mathLib.minimum (numericItem1, numericItem2)Returns the lesser of numericItem1 and numericItem2 mathLib.modf result = mathLib.modf (numericItem1, numericItem2)Splits numericItem1 into integral and fractional parts, both with the same sign as numericItem1; places the integral part in numericItem2; and returns the fractional part mathLib.pow result = mathLib.pow (numericItem1, numericItem2)Returns numericItem1 raised to the power of numericItem2 mathLib.precision result = mathLib.precision (numericItem)Returns the maximum precision (in decimal digits) for numericItem mathLib.round result = mathLib.round (numericItem, integer)result = mathLib.round (numericExpression)Rounds a number or expression to a nearest value (for example, to the nearest thousands) and returns the result mathLib.sin result = mathLib.sin (numericItem)Returns sine of numericItem mathLib.sinh result = mathLib.sinh (numericItem)Returns hyperbolic sine of numericItem mathLib.sqrt result = mathLib.sqrt (numericItem)Returns the square root of numericItem if numericItem is greater than or equal to zero mathLib.tan result = mathLib.tan (numericItem)Returns the tangent of numericItem mathLib.tanh result = mathLib.tanh (numericItem)Returns the hyperbolic tangent of numericItem
Related reference
Assignments
EGL statements
EGL statements
Exception handling
Numeric expressions
Primitive types
System words
System words in alphabetical order