Description

Arithmetic operators form arithmetic expressions which BASIC+ evaluates according to a strict order of priority.

Syntax

result = expression [operator expression ...]

Operators

PriorityOperatorKeyboard Symbol
high 1unary plus+
1unary minus-
2exponentiation**
3multivalued multiplication***
3multivalued division///
3multiplication*
3division/
4multivalued addition+ + +
4multivalued subtraction---
4addition+
4subtraction-
5multivalued concatenation:::
low 5concatenation :

Valid Arithmetic Operators

The valid arithmetic operators in BASIC+ are listed in the chart above.

An expression may have more than one operator. Each operation has a priority rating. BASIC+ scans the entire expression and begins the evaluation with the operator that has the highest priority. If two or more operators have the same priority in a given expression, evaluation proceeds from left to right.

Parentheses

Parentheses may be used to alter the order of the priority. Expressions that are enclosed within parentheses are evaluated prior to expressions without parentheses. Parentheses may also be used anywhere in an expression to clarify its order or to increase readability of the program.

See Also

Arithmetic expressions, Multi-value Arithmetic operators

Example

24 /2 * 4
The result will be 48.  Multiplication and division have the same priority.
24 / ( 2 * 4 ) = 3
The result will be 3.  The expression within the parentheses is evaluated first.
  • No labels