Divides an arithmetic value by an arithmetic value and returns the quotient with a specified precision and an optionally specified scale factor.
DIVIDE(x,y,p)
or
DIVIDE(x,y,p,q)
x and y are arithmetic values, and p and q are integer constants that represent precision and scale factor, respectively.
DECLARE SUM FIXED BINARY(15); . . . PUT LIST ('HALF PRICE IS'||DIVIDE (SUM, 2, 15));
The parameter q must not occur unless the result type is decimal.
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.