Skip to content

Operator Integer Divide

Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › Operators › Operator \ (Integer Divide)

Operator \ (Integer Divide)

Divides two Integer expressions

Syntax

Declare Operator \ ( ByRef lhs As Integer, ByRef rhs As Integer ) As Integer
Declare Operator \ ( ByRef lhs As UInteger, ByRef rhs As UInteger ) As UInteger

Parameters

  • lhs
  • rhs

Description

Operator \ (Integer division) divides two Integer expressions and returns the result. Float numeric values are converted to Integer by rounding up or down, and the fractional part of the resulting quotient is truncated.

If the divisor (rhs) is zero (0), a division by zero error (crash) will be raised.

Neither of the operands are modified in any way.

This operator can be overloaded for user-defined types.

Return Value

Returns the quotient of an Integer dividend and divisor.

Remarks

Usage

result = lhs\rhs

Dialect Differences

  • In the -lang qb dialect, this operator cannot be overloaded.

Differences from QB

  • None

See also

Examples

Dim n As Double

Print n \ 5

n = 7 \ 2.6  '' => 7 \ 3  => 2.33333  => 2

Print n

n = 7 \ 2.4  '' => 7 \ 2 => 3.5 => 3

Print n

Sleep

Output:

0
2
3

Category: Operators
Kind: operator


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally