This document covers the following topics:
Related Statements: ADD | COMPRESS |
                  								COMPUTE |
                  								DIVIDE |
                  								EXAMINE |
                  								MOVE |
                  								MOVE ALL |
                  								MULTIPLY |
                  								RESET |
                  								SEPARATE 
               
Belongs to Function Group: Arithmetic and Data Movement Operations
The SUBTRACT statement is used to subtract one or more
                  										arithmetic expressions or operands from another operand. 
               
| SUBTRACT[ROUNDED] | 
 | 
 |  | FROMoperand2 | 
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| operand1 | C | S | A | N | N | P | I | F | D | T | yes | no | |||||||
| operand2 | S | A | M | N | P | I | F | D | T | yes | no | ||||||||
Syntax Element Description:
| Syntax Element | Description | 
|---|---|
| arithmetic-expression | See
                           																		Arithmetic
                              																		Expression in the COMPUTEstatement. | 
| 
                                 																				Operands:     As for the formats of the operands, see also Rules for Arithmetic Assignments, Performance Considerations for Mixed Formats in the Programming Guide. | |
| ROUNDED |  ROUNDED Option: If you specify the keyword  For information on rounding, see Rules for Arithmetic Assignment, Field Truncation and Field Rounding in the Programming Guide. | 
| SUBTRACT[ROUNDED] | 
 | 
 |  | FROM | 
 | 
 | GIVINGoperand3 | |||
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| operand1 | C | S | A | N | N | P | I | F | D | T | yes | no | ||||||||
| operand2 | C | S | A | N | N | P | I | F | D | T | yes | no | ||||||||
| operand3 | S | A | M | A | U | N | P | I | F | B* | D | T | yes | yes | ||||||
* Format B of operand3 may
                  										be used only with a length of less than or equal to 4. 
               
Syntax Element Description:
| Syntax Element | Description | 
|---|---|
| arithmetic-expression | See
                           																		Arithmetic
                              																		Expression in the COMPUTEstatement. | 
| GIVING | GIVING
                                 																				Clause: When the  | 
|  Operands:     As for the formats of the operands, see also the section Performance Considerations for Mixed Formats in the Programming Guide. | |
| ROUNDED |  ROUNDED Option: If you specify the keyword  For information on rounding, see Rules for Arithmetic Assignment, Field Truncation and Field Rounding in the Programming Guide. | 
** Example 'SUBEX1': SUBTRACT ************************************************************************ DEFINE DATA LOCAL 1 #A (P2) INIT <50> 1 #B (P2) 1 #C (P1.1) INIT <2.4> END-DEFINE * SUBTRACT 6 FROM #A WRITE NOTITLE 'SUBTRACT 6 FROM #A ' 10X '=' #A * SUBTRACT 6 FROM 11 GIVING #A WRITE 'SUBTRACT 6 FROM 11 GIVING #A ' 10X '=' #A * SUBTRACT 3 4 FROM #A GIVING #B WRITE 'SUBTRACT 3 4 FROM #A GIVING #B ' 10X '=' #A '=' #B * SUBTRACT -3 -4 FROM #A GIVING #B WRITE 'SUBTRACT -3 -4 FROM #A GIVING #B' 10X '=' #A '=' #B * SUBTRACT ROUNDED 2.06 FROM #C WRITE 'SUBTRACT ROUNDED 2.06 FROM #C ' 10X '=' #C * END
SUBTRACT 6 FROM #A #A: 44 SUBTRACT 6 FROM 11 GIVING #A #A: 5 SUBTRACT 3 4 FROM #A GIVING #B #A: 5 #B: -2 SUBTRACT -3 -4 FROM #A GIVING #B #A: 5 #B: 12 SUBTRACT ROUNDED 2.06 FROM #C #C: 0.3