DIVIDE

Function

Divides one number into another.

Syntax

DIVIDE {src_num_lit|_var|_col} INTO dst_num_var
[ON‑ERROR={HIGH|ZERO}][ROUND=nn]

Arguments

src_num_lit|_var|_col

Divided into the contents of dst_num_var.

dst_num_var

Result after execution.

ON-ERROR

Sets the result to the specified number when a division by zero is attempted. If ON-ERROR is omitted and a division by zero is attempted, Production Reporting halts with an error message.

ROUND

Rounds the result to the specified number of digits to the right of the decimal point. For float variables, this value can be from 0 to 15. For decimal variables, this value can be from 0 to the precision of the variable. For integer variables, this argument is not appropriate.

Description

The source field is divided into the destination field and the result is placed in the destination. The source is always first, the destination always second.

When dealing with money-related values (dollars and cents), use decimal variables rather than float variables. Float variables are stored as double precision floating point numbers, and small inaccuracies can appear when dividing many numbers in succession. These inaccuracies can appear due to the way different hardware and software implementations represent floating point numbers.

Examples

divide  37.5  into  #price   ! #price / 37.5
divide  &rate  into  #tot  on-error=high
divide  #j  into  #subtot  on-error=zero

Note:

High in the preceding example is the “Maximum Value,” while zero is the “Lowest Value.”

See Also