數字運算子

數字運算子最簡單,幾乎與其他語言相同。

  • +, - ,*和/。加法,減法,乘法和除法運算子(在 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.