DIVIDE
Syntax
DIVIDE {src_num_lit|_var|_col} INTO dst_num_var [ON-ERROR={HIGH|ZERO}][ROUND=nn]
Description
Divides one number into another.
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 many numbers are divided in succession. These inaccuracies can appear due to the way different hardware and software implementations represent floating point numbers.
Parameters
| Parameter | Description |
|---|---|
|
src_num_lit|_var|_col |
Divided into the contents of dst_num_var. |
|
dst_num_var |
Contains the 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, SQR 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. |
Example
The following example illustrates the DIVIDE command:
divide 37.5 into #price ! #price / 37.5
divide &rate into #tot on-error=high
divide #j into #subtot on-error=zero
Note:
In the preceding example, High is the maximum
value and zero is the lowest value.
See ADD
See The LET command for a discussion
of complex arithmetic expressions