Arithmetic: Expressions and Type Conversions
Arithmetic follows the conventions used in most languages. The symbols
^ / * - +
denote exponentiation, division, multiplication, subtraction, and addition, respectively, and are applied in the order of precedence given. Arbitrary numbers of parenthesis may be used to make the order of evaluation explicit; expressions within parenthesis are evaluated before anything else, and inner parenthesis are evaluated first. As an example, FISH evaluates the variable xx as 133:
xx = 6/3*4^3+5
The expression is equivalent to:
xx = ( (6/3) * (4^3) ) + 5
If there is any doubt about the order in which arithmetic operators are applied, then parentheses should be used for clarification.
If either of the two arguments in an arithmetic operation is of floating-point type, then the result will be floating-point. If both of the arguments are integers, then the result will be integer. It is important to note that the division of one integer by another causes truncation of the result. For example, 5/2 produces the result 2, and 5/6 produces the result 0.
Was this helpful? ... | PFC 6.0 © 2019, Itasca | Updated: Nov 19, 2021 |