Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Operation ordering z/OS UNIX System Services User's Guide SA23-2279-00 |
|
Expressions can contain several operations, as in:
As
is customary in mathematics, all multiplications and divisions and
remainder operations are performed before additions and subtractions.
When handling the foregoing expression, awk performs B*C first
and then adds A. The value of:
is
therefore 14 (3*4 first, then add 2). If you want a particular operation
done first, enclose it in parentheses, as in:
When
evaluating this expression, awk performs
the addition before the multiplication. Therefore:
is
20 (2+3 first, then multiply by 4). As an example of this, consider
the program:
$4 is
the amount of money a person spent on a hobby in the last year. $3 is
the average number of hours a week the person spent on that hobby,
so $3*52 is the number of hours in 52 weeks (that
is, 1 year). $4/($3*52) is therefore the amount of
money that the person spent on the hobby per hour.An order-of-operations table for awk can be found in the awk command description in z/OS UNIX System Services Command Reference. |
Copyright IBM Corporation 1990, 2014
|