SUBTRACT Function

Purpose

SUBTRACT is functionally the same as ADD. It returns the sum of two arithmetic values.

Syntax

ADD(x,y,p,[q])

Parameters

x and y are arithmetic values, and p and q are integer constants that represent precision and scale factor, respectively.

Description

SUBTRACT(x,y,p) returns the arithmetic value x+y with precision and scale (p,0). ADD(x,y,p,q) returns x+y with precision and scale (p,q). The result has the common data type of x and y. If the arguments differ, they are converted as described in the section Arithmetic to Arithmetic Conversion in the chapter Data Type Conversions.

The ADD function can also be used for subtraction. To subtract, precede the operand to be subtracted with a minus sign.

Examples

DECLARE (PRICE, TAX) DECIMAL(5,2);
   .
   .
   .
PUT LIST ('TOTAL COST IS' || 
      SUBTRACT (PRICE, TAX, 6,2));

Restrictions

The parameter q must not be specified unless the result type is decimal.