[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Radtest
provides the common arithmetic operators, which
follow normal precedence rules (see section 13.2.6.8 Operator Precedence (How Operators Nest)), and work as
you would expect them to. The only notable exception is subtraction
operator (minus) which can be used as part of a variable or attribute
name, and therefore expressions like $x-3
are ambiguous. This
expression can be thought of either as a dereference of the variable
x-3
(see section 13.2.4.3 Dereferencing Variables), or as subtraction of the value
3
from the value of the variable x
. Radtest
always resolves this ambiguityin the favor of variable dereference.
Therefore we advise you to always surround minus sign by whitespace,
if it is used as a subtraction operator. So, instead of $x-3
,
write $x - 3
. For other methods of solving this ambiguity,
See minus-ambiguity.
This table lists the arithmetic operators in order from highest precedence to lowest:
- x
+ x
x
.
<FIXME> Should this
imply converting x to integer? </>
x * y
x / y
x % y
x + y
x - y
Unary plus and minus have the same precedence, the multiplication, division and remainder all have the same precedence, and addition and subtraction have the same precedence.
If x and y are of different data types, their values are first coerced to a common data type, selected using a set of rules (see section 13.2.6.6 Conversion Between Data Types).