DIV examples

Last Updated : Sep 08, 2012 |

The following table provides examples for using the DIV operator. The DIV operator divides operand1 by operand2.

Command

Result

set A = A DIV 10

A = 000123

120 / 10 = 12

Leading zeros are ignored and the results are not padded with leading zeros.

setA = A DIV 2

A = 5

5 / 2 = 2.5 = 2

The result is rounded down to the nearest whole integer. Results do not contain any decimal values.

set A = A DIV 1000

A = 000123

123 / 1000 = 0.123 = 0

The result is rounded down to the nearest whole integer.

setA = A DIV A

A = 9999999999

# / # = #

This operation is an operand overflow because the operand values exceed 4294967295.

set A = A DIV #

A = 000123

000123 / # = #

A # character in an operand makes the operation invalid (#).

set B = A DIV 100

Variable definitions:

  • A = 12345678

  • B: collect type, length = 4, start = 3 (start is ignored)

12345678 / 100 = 123456.78 = 123456 = #

The result is rounded down to the nearest integer, but it is an invalid result (#) because it is greater than four digits.

set B = A DIV 100

Variable definitions:

  • A = 12345678

  • B: collect type, length = 6, start = 3 (start is ignored)

12345678 / 100 = 123456.78 = 123456

The result is rounded down to the nearest integer. This result is valid because the result is six digits in length.