REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |

TOC < Back Next > | Updated: 6-Feb-2009 Edit History |

There are two rules to remember when evaluating mathematical expressions:

- ''Expressions are evaluated from left to right.
- ''Operators take precedence over functions.

The evaluation of expressions from left to right is independent of the type of operator that is used. For example:

```
print 1 + 2 * 3
9
```

In the example above, notice that the result is not seven, as would be the case if multiplication took precedence over addition.

If you need to evaluate in some other order, reorder the expression or use parentheses:

```
print 2 * 3 + 1
7
```

```
print 1 + (2 * 3)
7
```

When functions are mixed with operators, the operators are evaluated first, then the functions:

```
print absolute -10 + 5
5
```

In the above example, the addition is performed first, and its result is provided to the absolute function.

In the next example:

print 10 + sine 30 + 60 11 30 + 60 => 90 sine 90 => 1 10 + 1 => 11 print

To change the order such that the sine of 30 is done first, use parentheses:

```
print 10 + (sine 30) + 60
70.5
```

or reorder the expression:

```
print 10 + 60 + sine 30
70.5
```

TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |