The xcpp preprocessor allows for evaluation of expressions in a similar manner to the C/C++ compiler.
The following table shows the operators and their precedence (highest precedence at the top of the table):
Operator | Description |
---|---|
! |
Logical negation Bitwise negation Unary minus Unary plus |
^^
|
Power |
* |
Multiplication Division Modulus |
+ |
Addition Subtraction |
<< |
Bitwise shift left Bitwise shift right |
< |
Comparison less-than Comparison less-than-or-equal-to Comparison greater-than Comparison greater-than-or-equal-to |
== |
Comparison equal-to Comparison not-equal-to |
&
|
Bitwise AND |
^
|
Bitwise XOR |
|
|
Bitwise OR |
&&
|
Logical AND |
||
|
Logical OR |
? :
|
Ternary conditional (if-then-else) |
Expressions are evaluated in the following circumstances:
The supported types are bool
, int
, double
, char
and string
.
Unlike C/C++ there is no implicit conversion from int
to bool
.
The trigonometric functions sin
, cos
and tan
are available. Also
the exponential exp
, and natural logarithm log
(base e).
Before translation | After translation |
---|---|
|
|