7 + 2 * 3 - 1
\___/
6
3. Addition and subtraction from left to right
7 + 6 - 1 = 12
Using Arithmetic Expressions
You can use arithmetic expressions in a program many different ways. The following example uses several
arithmetic operators to round and remove extra decimal places from a dollar and cents value.
Exercises—Calculating Arithmetic Expressions
1. What line of output does the following program produce?
/****************************** REXX ******************************/
pa = 1
ma = 1
kids = 3
SAY "There are" pa + ma + kids "people in this family."
2. What is the value of:
a. 6 - 4 + 1
b. 6 - (4 + 1)
c. 6 * 4 + 2
d. 6 * (4 + 2)
e. 24 % 5 / 2
ANSWERS
1. There are 5 people in this family.
2. The values are as follows:
a. 3
b. 1
c. 26
d. 36
e. 2
Comparison Operators
Expressions that use comparison operators do not return a number value as do arithmetic expressions.
Comparison expressions return either
1
, which represents true, or
0
, which represents false.
Comparison operators can compare numbers or strings and perform evaluations, such as:
Are the terms equal? (
A = Z
)
Is the first term greater than the second? (
A > Z
)
Is the first term less than the second? (
A < Z
)
/****************************** REXX *********************************/
/* This program computes the total price of an item including sales
*/
/* tax, rounded to two decimal places.
The cost and percent of the
*/
/* tax (expressed as a decimal number) are passed to the program
*/
/* when you run it.
*/
/*********************************************************************/
PARSE ARG cost percent_tax
total = cost + (cost * percent_tax)
/* Add tax to cost.
*/
price = ((total * 100 + .5) % 1) / 100
/* Round and remove extra
*/
/* decimal places.
*/
SAY 'Your total cost is £'price'.'
Figure 11. Example Using Arithmetic Expressions
Using Variables and Expressions
Chapter 3. Using Variables and Expressions
23
Содержание SC34-5764-01
Страница 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Страница 2: ......
Страница 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Страница 22: ...xx CICS TS for VSE ESA REXX Guide...
Страница 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Страница 24: ...2 CICS TS for VSE ESA REXX Guide...
Страница 40: ...18 CICS TS for VSE ESA REXX Guide...
Страница 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Страница 106: ...84 CICS TS for VSE ESA REXX Guide...
Страница 110: ...88 CICS TS for VSE ESA REXX Guide...
Страница 122: ...100 CICS TS for VSE ESA REXX Guide...
Страница 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Страница 124: ...102 CICS TS for VSE ESA REXX Guide...
Страница 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Страница 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Страница 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Страница 252: ...230 CICS TS for VSE ESA REXX Guide...
Страница 278: ...256 CICS TS for VSE ESA REXX Guide...
Страница 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Страница 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Страница 340: ...318 CICS TS for VSE ESA REXX Guide...
Страница 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Страница 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Страница 400: ...378 CICS TS for VSE ESA REXX Guide...
Страница 438: ...416 CICS TS for VSE ESA REXX Guide...
Страница 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Страница 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Страница 448: ...426 CICS TS for VSE ESA REXX Guide...
Страница 464: ...442 CICS TS for VSE ESA REXX Guide...
Страница 466: ...444 CICS TS for VSE ESA REXX Guide...
Страница 468: ...446 CICS TS for VSE ESA REXX Guide...
Страница 476: ...454 CICS TS for VSE ESA REXX Guide...
Страница 478: ...456 CICS TS for VSE ESA REXX Guide...
Страница 479: ......
Страница 480: ...SC34 5764 01...
Страница 481: ...Spine information CICS TS for VSE ESA REXX Guide...