Where a variable is to be used as input to an arithmetic expression, the variable should be enclosed in parentheses to ensure that it is evaluated before an operator is applied to it. This is important where the variable contains a signed number.
For example, consider the following:
&A ** 2
When &A contains 5, the value is 25. However, if &A contained -5, the answer would be -25. This is due to NCL substitution, which evaluates the expression as follows:
-5 ** 2 = -(5 ** 2) = -25
To ensure that the sign of the variable value is interpreted correctly, parentheses should be used as follows:
(&A) ** 2
This will give the correct answer of 25.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |