数字运算符
数字运算符最简单,几乎与其他语言相同。
- +, - ,*和/。加法,减法,乘法和除法运算符(在 VFP 中没有整数除法,可以将结果转换为带有函数
INT()
,CEILING()和FLOOR()
的整数。 - %模数运算符。
- ^和**。运算符的力量。他们都做同样的事情。
- ()。分组运算符。
- 运算符优先。订单是:
( ) ^ (or **) / and * - and +
? 10 / 5 + 2 && Outputs 4
? 2 + 10 / 5 && Outputs 4 as well. Division has precedence.
* Both multiplication and division have same precedence
* They would be interpreted from left to right.
? 4 * 5 / 2 + 5 && Outputs 15
* Use parentheses whenever you are in doubt or want to be explicit
? ( (4 * 5) / 2 ) + 5 && Outputs 15. Explicit grouping of operations
? 4 * 5^2 && ^ has precedence, this is same as 4 * (5^2) = 100.
? (4 + 5)^2 && Using parentheses we say add 5 to 4 (9) and then square = 81.