Skip to main content

DIV

Integer division of two values.

Synopsis

DIV(numstr1,numstr2)

Arguments

numstr1 The dividend. An expression that resolves to a number or numeric string.
numstr2 The divisor. An expression that resolves to a non-zero number or numeric string.

Description

The DIV function divides the value of numstr1 by numstr2, and returns the integer quotient. It discards the fractional remainder. If a numstr value is a null string or a non-numeric value, DIV parses its value as 0 (zero).

Attempting to divide by zero generates a <DIVIDE> error, ending execution of the function and invoking an error trap handler, if available.

To perform exact division with a fractional quotient, use the division operator (/). To perform modulo division, use the MOD or REM function.

To perform division on the elements of a dynamic array, use the DIVS (divide corresponding elements, generate error on a zero divisor value), DIVSZ (divide corresponding elements, return 0 for a zero divisor value), and MODS (modulo division of corresponding elements) functions The DIVS and DIVSZ functions can return fractional numbers as the result (quotient) of a division operation.

Examples

The following examples use the DIV function to return the integer quotient of a division operation:

PRINT DIV(10,5);      ! returns 2
PRINT DIV(10,4);      ! returns 2
PRINT DIV(10,3.3);    ! returns 3
PRINT DIV(10,3.4);    ! returns 2
PRINT DIV(10.2,3.4);  ! returns 3
PRINT DIV(10,-3);     ! returns -3
PRINT DIV(-10,3);     ! returns -3

See Also

FeedbackOpens in a new tab