z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Using Arithmetic Expressions

z/OS TSO/E REXX User's Guide
SA32-0982-00

You can use arithmetic expressions in an exec many different ways. The following example uses several arithmetic operators to round and remove extra decimal places from a dollar and cents value.

Example Using Arithmetic Expressions

/****************************** REXX *******************************/
/* This exec 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 exec when */
/* it is run.                                                      */
/*******************************************************************/

 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'.'

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014