Parent Topic: Language

Arithmetic Expressions

Arithmetic expressions are made up of arithmetic elements and arithmetic operators. The evaluation of an arithmetic expression yields a single numeric value. Arithmetic elements consist of: numeric constants, numeric variables, layer variables, numeric attribute variables, numeric array variables and special variables. Available operators are listed in the following sections.

Examples of arithmetic expressions are:

        10.3
        sin(%3) * 27.05 - (2+ln(#temp))
        min(%1,%2,%3) * and(%6,15)
Operators
The following arithmetic operators are available with standard algebraic precedence being observed:

        '-x'            negation
        '^'             exponentiation
        '/'             division
        '*'             multiplication
        '+'             addition
        '-'             subtraction
        '()'            parenthesis
Single Value Functions
The following single value arithmetic functions are available:

        sin   (e)               sine
        cos   (e)               cosine
        tan   (e)               tangent
        asin  (e)               arc sine
        acos  (e)               arc cosine
        atan  (e)               arc tangent
        deg   (e)               radians to degrees
        rad   (e)               degrees to radians
        ln    (e)               natural logarithm
        exp   (e)               natural exponent
        log10 (e)               base 10 logarithm
        exp10 (e)               base 10 exponent
        int   (e)               integer  part of real
        frac  (e)               fraction part of real
        abs   (e)               absolute value
where:

          e  can be any arithmetic expression.
          Arguments for trigonometric functions MUST be expressed 
          in radians.
example:

          int(tan(2.3 * ln(%6)))
Multi Value Functions
The following multi value arithmetic functions are available:

    atan2 (v1,v2)           arc tan (v1/v2) using signs of v1,v2
    mod   (v1,v2)           remainder of v1/v2
    min   (v1,v2,...,vn)    minimum value of v1,v2,...,vn
    max   (v1,v2,...,vn)    maximum value of v1,v2,...,vn
where

    v1,v2,...,vn            are arithmetic elements, excluding
                            attribute variables.
example:

    min (%1, %2, #temp, 25.5, @dbx)
Bit Manipulation Functions
The following bit manipulation functions are available. They are accomplished by converting passed values to integers, performing the logical operation on all the bits, and converting back. 'not' operations should be followed by an 'and' to remove high bits.

    not (v1)                logical not
    and (v1,v2,...,vn)      logical and
    or  (v1,v2,...,vn)      logical inclusive or
    xor (v1,v2,...,vn)      logical exclusive or
where

    v1,v2,...,vn            are arithmetic elements, excluding
                            attribute variables.
example:

    #t = not(%1); #t= and(#t,255);   | to ensure only 8 bits

Parent Topic: Language
About PCI Help Gateway