DIVIDE Function

Purpose

Divides an arithmetic value by an arithmetic value and returns the quotient with a specified precision and an optionally specified scale factor.

Syntax

DIVIDE(x,y,p)

or

DIVIDE(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

The DIVIDE function divides an arithmetic value, x, by an arithmetic value, y, and returns the quotient with a specified precision p and an optionally specified scale factor q.

The result is xly, having the common data type of x and y.

The precision of the result is (p,q) or (p). In the latter case, q equals zero.

If y equals zero, the program is in error and the ZERODIVIDE condition is raised.

Examples

DECLARE SUM FIXED BINARY(15);
   .
   .
   .
PUT LIST ('HALF PRICE IS'||DIVIDE (SUM, 2, 15));

Restrictions

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