Div Command

Purpose

Divides a numeric variable by a numeric expression.

Syntax

Div x, y( command)

% = i Div j)( operator)

% = Div(i, j)( function)

x:numeric variable
y:any numeric expression
i, j:integer expression

Description

Div x, y divides the expression y into the value in variable x. It depends on the type of the variable x which whether the division is an integer or a floating-point division.

The operator i Div j and function Div(i, j, …) return an integer value. In case one of the parameters isn't an integer, it is converted to a 32-bit values first (using CInt).

Example

Debug.Show

Dim b# = 7.5

Trace b# Div 3          // CInt(b#) \ 3 = 2

Trace Div(b#, 3)        // CInt(b#) \ 3 = 2

Div b#, 3 : Trace b#    // b# = 2.5

b# = 8.5

Trace b# Div 3          // CInt(b#) \ 3 = 2

Trace Div(b#, 3)        // CInt(b#) \ 3 = 2

Div b#, 3 : Trace b#    // b# = 2.833333333333

Remarks

The following can be used instead of Div x, y:

x = x / y

x := x / y

x /= y

See Also

+, -, *, /, \, Add, Sub, Mul, Div, ++, --, +=, -=, /= , *=, Operator Hierarchy

{Created by Sjouke Hamstra; Last updated: 24/06/2017 by James Gaite}