Operators
JBEE recognizes the following operators:
- Basic arithmetics: +, -, * and /
-
These are the standard infix operators for addition, subtraction, multiplication and division. For example
5+10*2
will evaluate to 25. All operators except division use unlimited precision by default. - Binary: #, |, &, >>, << and ~
- All binary operators require integer values and bind weaker than the basic arithmetic operators. The # operator implements XOR since the ^ symbol is already used for exponentiation.
- Power: ^
- Raises a base value to the power of an exponent. For example,
2^4
will evaluate to 16. In the default implementation, the exponent must be integer. - Remainder: %
- The remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division). For example,
8%3
will evaluate to 2. - Move: :
- The
:
moves the decimal point by n places according to sign. It may be used to emulate scientific notation. For example,1.2:-2
will evaluate to 0.012 while1.2:2
will evaluate to 10.2 and1.2:0
leaves the point in place. - Mercantile: +% and -%
- Adds or subtracts a percentage from a value. For example
100 -% 25
will evaluate to 75. - Brackets: ( and )
- Brackets change precedence. For example,
(3+7)/2
will evaluate to 5.