Arithmetic operators

Number + Number Adds two numbers.
- Number Computes the opposite sign of a number. Zero is the opposite of itself.

N = 5
R = -8
PRINT N;" ! ";R; " , "; -N ; " !! "; -R

==> 5 ! -8 , -5 !! 8

Number - Number Subtracts two numbers.
Number * Number Multiplies two numbers.
Number / Number Divides two numbers. A division by zero error will occur if the value of the number to the right of the slash is zero.
Number ^ Power Raises Number to the power Power .

PRINT 4^3

==> 48

Number \ Number Computes the quotient of the two numbers. A division by zero error will occur if the value of the number to the right of the backslash is zero. A \ B is the equivalent of INT(A/B).

PRINT 9\4; " , "; 9 MOD 4

==> 2 , 1

Number AND Number Computes the mathematical and of the binary value of the two numbers.

PRINT 5 AND 3

==> 1

Number MOD Number Computes the remainder of the quotient of the two numbers. A division by zero error will occur if the value of the number to the right of the operator MOD is zero.

PRINT 9\4; " , "; 9 MOD 4

==> 2 , 1

Number OR Number Computes the mathematical or of the binary value of the two numbers.

PRINT 5 OR 3

==> 7

Number XOR Number Computes the mathematical exclusive or of the binary value of the two numbers.

PRINT 5 XOR 3

==> 6


See also Abs, AND, NOT, OR, Sgn XOR

Previous: AND Next: Array