qck.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Arithmetic Operators
                                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 Arithmetic Operators
 
 ■ Visual Basic provides the following arithmetic operators (in order of
   precedence):
 
         Operator   Usage
         ════════   ════════════════════════════════════════════════════════
         ^          Exponentiation
         -          Negation
         *, /       Multiplication and division
         \          Integer division
         MOD        Modulo division
         +, -       Addition and subtraction
 
 ■ Parentheses change the order in which arithmetic operations are performed.
   Operations within parentheses are performed first. Inside parentheses, the
   usual order of operation is maintained.
 
 ■ Generally, two consecutive operators must be separated by parentheses.
   Exceptions to this rule are * -, * +, ^ -, and ^ +.
 
 ■ Integer division is denoted by the backslash (\); the forward slash (/)
   indicates floating-point division. Before integer division is performed,
   operands are rounded to integers or long integers, and so must be greater
   than -2,147,483,648.5 and less than 2,147,483,647.5. The quotient of an
   integer division is truncated to an integer. For example:
 
         PRINT 7 \ 2, 7 / 2, -32768.499 \ 10, -32768.499 / 10
 
   where the output is:
 
         3             3.5          -3276         -3276.8499
 
 ■ Modulo arithmetic is denoted by the modulus operator MOD. Modulo
   arithmetic provides the remainder, rather than the quotient, of an
   integer division. For example:
 
         X% = 7 \ 2
         REMAINDER% = 7 - 2*X%       '7 = 2*3, with remainder 1
         PRINT REMAINDER%, 7 MOD 2
 
   where the output is:
 
         1             1
 
 ■ The following operations produce run-time errors that can be trapped by an
   error-trapping routine:
   • Dividing by zero
   • Raising zero to a negative power
   • Arithmetic overflow
   See: Error/Event Trapping Summary
 
 See: Expressions and Operators Summary  Hierarchy of Operations