Arithmetic Functions

The following table describes arithmetic functions. The binary arithmetic functions like Add, Subtract, and Multiply return a result type that is the higher resolution type of the two parameters. For example, Add(Integer, Long) returns Long. Multiply(Integer, Double) returns Double. The Divide function always returns Double.

Arithmetic Functions

Function

Description

Absolute

Returns the absolute value (its numerical value without regard to its sign) of the numeric argument. Arguments are integer, long integer, or double.

Add

Returns the result of adding the two numeric arguments together. Arguments are integer, long integer, or double types.

Ceil

Returns the smallest integer value that is not less than the numeric argument. Arguments are integer, long integer, or double.

Divide

Returns the result of dividing the first numeric argument by the second numeric argument. Arguments are integer, long integer, or double types; but the second argument must not evaluate to 0.

Floor

Returns the largest integer value that is not greater than the numeric argument. Arguments are integer, long integer, or double.

Java Mathematical Expressions

Returns the result of the evaluation of the specified Java expression. Java Mathematical Expressions are for advanced users.

ESM does not provide error checking and messaging for your JEP (Java expression parser) expressions. Refer to the Java math expressions parser web pages at http://www.singularsys.com/jep/ for more information on writing these expressions.

Supported Expressions: ESM supports a subset of Java mathematical expressions parser (JEP), which are written like standard mathematical expressions. A JEP expression has three components: operator, function, and value.

  • Function - See http://www.singularsys.com/jep/doc/html/functions.html ESM supports the following functions, which are a subset of functions described in http://www.singularsys.com/jep/doc/html/functions.html.

    Supported Trigonometric Functions:
    sin(x)             cos(x)              asin(x)
    acos(x)            atan(x)             atan2(y, x)
    sinh(x)            cosh(x)             tanh(x)
    asinh(x)           acosh(x)            atanh(x)

    Supported Logarithmic and Exponential Functions:
    ln(x)             log(x)             exp(x)

    Miscellaneous Supported Functions:
    abs(x)                      rand()
    mod(x,y)= x % y      sqrt(x)

  • Value - The values are either constants of numeric type or fields, which are referenced by the camelCase notation, such as bytesIn.

    For information on how to reference fields, refer to the "Script Alias" names in Data Fields.

Example

The expression "(bytesIn^2)/1000" squares the bytesIn value of an event and divides the result by 1000.

 

Notes:

  • All JEP functions return a Double.

  • Unlike velocity references, JEP expressions do not use "$" in front of (ArcField) Data Fields.

  • Do not include mathematical operators or JME function names in a variable name. If you do, the JME parser interprets them as operators and returns unexpected results. Variable names that match JME function names such as sqrt cause similar problems.

  • Some expressions may not be valid and do not produce results. Do not use them in queries or active channels, and filters that use them cannot be used in queries or active channels.

  • JME variables are held only in memory and so, can be used only in Rules, Filters, and Data Monitors. They cannot be used in resources like Reports, which rely on persisted data. (There is a set of velocity references specifically for use in Reports. See Velocity References for Reports for more information.)

  • This function is held in memory, therefore you can only use it in Rules, Filters, and Data Monitors. You cannot use the function in resources like Queries and Reports, and other resources that rely on persisted data.

Multiply

Returns the product of multiplying the two numeric arguments together. The arguments may be integer, long integer, or double types.

Round

Returns the closest integer to the numeric argument. The argument must be a double.

RoundN

Takes two arguments, the double number to be rounded off and the number of decimal places from 0 to 5. Rounds off the input double number to the specified number of decimal places. For example:

If the double is 1.23456789 and you want to make it readable in your reports, use the RoundN function to set the decimal places to 2.

The double is rounded off to 1.23.

Subtract

Returns the result of subtracting the second numeric argument from the first numeric argument. The arguments may be integer, long integer, or double types.