Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Arithmetic operators z/OS UNIX System Services User's Guide SA23-2279-00 |
|||||||||||||||||||||||||
The following awk program uses simple arithmetic:
In
the print statement:
has
the value of the third field in the record, minus 10. This is the
value that print prints. If you apply this program to the hobbies file, the output is:
You could describe how the program works
like this: If someone spends more than 10 hours on a hobby, the program
prints the person's name, the name of the hobby, and how many extra hours the person spends on the hobby (that
is, the number of hours more than 10).An expression such as:
is
called an arithmetic expression. It performs
an arithmetic operation and comes up with a result, which is called
the value of the expression.awk recognizes the following arithmetic operations:
The remainder operation is also known as the modulus, or integer remainder operation. The
value of this expression is the integer remainder you get when you
divide A by B. For
example:
has a value of 1,
because dividing 7 by 3 gives you 2 with a remainder of 1.The value for the exponentiation operation:
is the value of A raised to the exponent B. For example:
has the value 9 (that is, 32). |
Copyright IBM Corporation 1990, 2014
|