Operators
You can specify values by using arithmetic operations on numbers, comparisons, and logical operations. These operations are specified by an infix operator (which is an operator between operands), or by a prefix operator (which is an operator in front of operands).
Arithmetic operations
-DOWN_TIME
+40
-23.456
-1E8
The result is of the same type as the
operand. The prefix plus (+) does not change its operand. The prefix minus (-) reverses the sign of
its operand.A+B
N_DATASETS-5
COUNT*1E-6
RESP_TIME/60
The result depends on the
operand types:- If both operands are integers, the result is an integer. The operation is performed using integer arithmetic. The division is performed so that the remainder has the same sign as the dividend.
- If both operands are floating-point numbers, the result is a floating-point number. The operation is performed using long floating-point operations of S/390®.
- If one of the operands is an integer and the other a floating-point number, the integer is converted to a floating-point number. The operation is then performed on the result of the conversion, using floating-point arithmetic. The result is a floating-point number.
The result of dividing an integer by another integer is also an integer. For example, if
RESP_TIME
is an integer less than 60, the result of RESP_TIME/60
is 0. If you want the exact result, write RESP_TIME/60.0
instead, which makes the
operand on the right the floating-point number 60.0. Then the operand on the left, which is
RESP_TIME
, is converted to a floating-point number, making the result a
floating-point number.
For all operators, the result is null if any of the operands is null. If the result is an integer, the result must be within the range of integers. If the result is a floating-point number, the result must be within the range of floating-point numbers. The operand on the right of a divide operator must not be 0.
Comparisons
A>10
JOB_NAME<'ABC'
DATE<>'1993.04-15'
Only the
following types of comparisons are allowed:- Numbers with numbers
- Character strings with character strings or date and time values
- Date and time values with character strings or date and time values of the same type
Numbers are compared by their algebraic values. If both numbers are floating-point numbers, they are compared by using long floating-point operation of S/390. Two floating-point numbers are considered equal only if their normalized forms have identical bit configurations.
If one of the numbers is an integer number and the other a floating-point number, the integer number is converted to a floating-point number. The comparison is then performed with the result of the conversion.
Character strings are compared byte by byte, left to right. If the strings are different in length, the comparison is made with a temporary copy of the shorter string that is extended on the right with the necessary number of blanks so that it has the same length as the other string..
Two strings are equal if they are both empty or if all corresponding bytes are equal. Otherwise, their relation is determined by the comparison of the first unequal pair of bytes.
When a character string is compared with a date and time value, it must be a valid date and time string of the corresponding kind. The string is converted to a date and time value and the comparison is performed on the result.
All comparisons of date and time values are chronological. The value that represents the later point of time is considered to be greater.
TIMESTAMP('1985-02-23-00.00.00.000000')>TIMESTAMP('1985-02-22-24.00.00.000000')
However,
the INTERVAL
calculates the interval between these timestamps as 10.Logical operations
NOT
to any value of true or false. The
following table shows the result that is defined for operand p
:
p |
NOT p |
---|---|
True | False |
False | True |
Unknown | Unknown |
AND
and OR
to any pair values
of true or false. The following table shows the result that is defined for operand
p
and q
:
p |
q |
p AND q |
p OR q |
---|---|---|---|
True | True | True | True |
True | False | False | True |
True | Unknown | Unknown | True |
False | True | False | True |
False | False | False | False |
False | Unknown | False | Unknown |
Unknown | True | Unknown | True |
Unknown | False | False | Unknown |
Unknown | Unknown | Unknown | Unknown |