To expand on the subject, this is from the help:
And you can perform the following operations on variables when using the equal sign:
%x = 5 + 1
%x = 5 - %y
%x = %x * 2
%x = %z / $2
%x = $1 % 3
%x = 2 ^ %w
You can only perform a single operation in an assignment at this time.
You can also use the $calc() identifier which allows you to perform complex calculations.
From the language used, I interpret this as follows:
- Any variable declared in the form A <op> B where A and B are *numeric* values should result in the code being treated as a mathematical calculation. Numeric values include 0, and can be variables (%z where %z is a number including 0).
- $calc() is an alternative identifier to accomplish calculations, and therefore $calc() should maintain a SUPERSET of the %x = A <op> B behaviour. Namely, assuming both A and B are numeric, %x = A <op> B should function the same as $calc(A <op> B), since it is documented as an alternative way to specify these calculations.
The help file therefore:
- Has explicit support for A % B
- Leaves A / 0 and A % 0 behaviour undefined, however:
- Uses an example of %z / $2 in which $2 could reasonably expected to be a numeric value such as 0, or even $null. Given that it's posed as an example, the expectation is that this will still work as a calculation.
- (Implicitly) refers the scripters to $calc() for the behaviour of these calculations.
I think it's pretty clear that there is an inconsistency here.