Arithmetic Operations

From BR Wiki
Revision as of 09:30, 9 January 2012 by Mikhail.zheleznov (talk | contribs) (edit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The four arithmetical operations supported by BR are addition, subtraction, multiplication and division. These operations literally correspond with their respective mathematical operators. All of these mathematical operators are examples of binary operators.

Operator Effect
+ addition
+= addition of the left operand to the right operand followed by assignment of the result to the left operand
- subtraction
-= subtraction of the right operand from the left operand followed by assignment of the result to the left operand
* multiplication
*= multiplication of the left operand by the right operand followed by assignment of the result to the left operand
/ division
/= division of the left operand by the right operand followed by assignment of the result to the left operand

Now consider two more operators that use the same signs as addition and subtraction, yet each perform a different function.

The first one is unary plus +. The result of the unary plus operator is the value of its operand. The operand to the unary plus operator must be a numeric variable.

For example,

00010 let b = - 1
00020 let a = + b

The second one is unary minus -. The result of the unary minus operator is the opposite value of its operand. The operand to the unary minus operator must be a numeric variable.

For example,

00010 let b = - 1
00020 let a = - b

As a result, the value of a becomes 1, which is the opposite of -1.