Math functions enable you to generate configuration parameters and to assist with tests. This section lists and describes the various math functions that you can use in iWay Service Manager.
The _add() function is used to add a list of terms. It uses the following format:
_add(term, term*)
term | number | Number to be added. |
This function returns the sum of the terms. There is nothing implied by the order of the terms.
The _sub() function is used to return the difference. It uses the following format:
_sub(minuend, subtrahend)
minuend | number | Number to be subtracted from. |
subtrahend | number | Number to be subtracted from the minuend. |
The _mod() function produces the remainder of dividing the first term by the second. For example, mod(22,6) = 4 because 22 / 6 = 3 with a remainder of 4. This is often written 22%6 in common arithmetic.
The _mod() function uses the following format:
_mod(term, modulus)
term | integer | Number to be divided. |
modulus | integer | Number to be used for testing. |
The _mul() function returns the product of the first factor multiplied by the second factor. Recall that multiplication is commutative and therefore there is nothing implied by the order of the factors.
The _mul() function uses the following format:
_mul(multiplicand, multiplier)
multiplicand | number | Number to be operated upon. |
multiplier | number | The multiplier for the function. |
The _div() function returns the quotient of the first factor divided by the second factor. This is a floating point number.
The _div() function uses the following format:
_div(dividend, divisor)
dividend | number | Number to be operated upon. |
divisor | number | The divisor for the function. Must be != 0. |
The _iadd() function returns the sum of the terms. There is nothing implied by the order of the terms. Any term can be an XPATH() function. If the XPATH() returns multiple results, all are added into the sum. All values are assumed to be integers, and the result is an integer. The iadd() function is suitable for date manipulation, as the addition is computed with sufficient precision to maintain the field integrity. See _dateof(): Return the Time Stamp for a Passed Time for examples.
The _iadd() function uses the following format:
_iadd(term, term*)
term | number | Number to be added. |
The _isub() function returns the difference with integer arithmetic. The isub() function is suitable for date manipulation, as the subtraction is computed with sufficient precision to maintain the field integrity. See _dateof(): Return the Time Stamp for a Passed Timefor examples.
The _isub() function uses the following format:
_isub(minuend, subtrahend)
minuend | number | Number to be subtracted from. |
subtrahend | number | Number to be subtracted from the minuend. |
The _imul() function returns the product of the first factor multiplied by the second factor. Recall that multiplication is commutative and therefore there is nothing implied by the order of the factors.
The _imul() function uses the following format:
_imul(multiplicand, multiplier)
multiplicand | number | Number to be operated upon. |
multiplier | number | The multiplier for the function. |
The _idiv() function returns the quotient of the first factor divided by the second factor. The quotient is an integer, with the fractional part disregarded.
The _idiv() function uses the following format:
_idiv(dividend, divisor)
dividend | number | Number to be operated upon. |
divisor | number | The divisor for the function. Must be != 0. |
The _int() function casts a value to an integer. This is done by ignoring the fractional part, as is the standard case for computer languages. To avoid loss of information, the _round() performs a similar operation with half-adjust rounding.
The _int() function uses the following format:
_int(value)
value | number | Number to be cast. |
The _intmask() function inserts a number into a character mask. It uses the following format:
_intmask(pattern,input)
pattern | string | Mask into which the number is inserted. All characters but # appear as-is, but # characters (one set) are replaced by the value. |
input | integer | Math value to be inserted. Must be present, if not, it will cause an error. |
_max(term, term*)
term | number | Number to be evaluated. |
Returns the maximum value of the terms. There is nothing implied by the order of the terms. Any term can be an XPATH() function. If the XPATH() returns multiple results, all are evaluated.
_min(term, term*)
term | number | Number to be evaluated. |
Returns the minimum value of the terms. There is nothing implied by the order of the terms. Any term can be an XPATH() function. If the XPATH() returns multiple results, all are evaluated.
The _random() function returns a pseudo-random integer between zero and the upper bound (with default 232-1). All possible values are produced with equal probability.
This function is especially useful as a seed for a cryptographic algorithm. It is also useful for simulating server response time distributions using the delay parameter of the copy agent. For example, to simulate a random execution time between 300 and 340 ms, specify a delay time of 300 +_random(40).
The _random() function uses the following format:
_random(upperbound)
upperbound | integer | Upper bounds. |
The _floor() function returns the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer. Special cases include:
For example, the floor of -7.5 is -8. The floor of 7.5 is 7.
The _floor() function uses the following format:
_floor(number)
number | value | Number to be operated upon. |
The _ceil() function returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. Special cases include:
Note: The value of ceil(x) is exactly the value of -floor(-x).
For example, the ceil of -7.5 is -7. The ceil of 7.5 is 8.
The _ceil() function uses the following format:
_ceil(number)
number | value | Number to be operated upon. |
The _round() function returns the closest integer to the argument value. The result is rounded to an integer by adding ½, taking the floor of the result, and casting the result to type integer. In other words, the result is equal to the value of the following expression:
(int)Math.floor(a + 0.5f)
The _round() function uses the following format:
_round(number)
number | value | Number to be operated upon. |
iWay Software |