Skip to content

Operator

Muqsit Rayyan edited this page Oct 9, 2022 · 17 revisions

Operators

arithmexp features two kinds of operators — unary, and binary. Below is a list of all operators featured by the library.

Operator Name
+ Binary Addition
/ Binary Division
** Binary Exponentiation
% Binary Modulo
* Binary Multiplication
- Binary Subtraction
- Unary Negative
+ Unary Positive

Operator Precedence

Operator precedence in arithmexp is at par with PHP's arithmetic operator precedence. Precedence of binary operators is governed by two attributes — a priority value (an integer), and associativity (left-associative or right-associative). If an operator ~ is left-associative, then x ~ y ~ z will be computed as (x ~ y) ~ z. If the operator were right-associative, the expression would be computed as x ~ (y ~ z). While there is no difference in the resulting value due to associativity type in the given expression, this may not always be the case when multiple operators are given the same precedence (such as in x / y * z / w when / and * are given the same precedence). You may read more about operator associativity here.

Below is a table of binary operators in ascending order of precedence.

Associativity Operators
Right-associative **
Left-associative * / %
Left-associative + -

1. Quick Start

1.1. Installation

2. Documentation Notes

2.1. Constant
2.2. Function
2.3. Macro
2.4. Operator
2.5. Variable
2.6. Expression Optimization
2.7. Implementation Internals

Clone this wiki locally