ACR Electronics FPR-10 PROGRAMMER Manuel Page 61

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 199
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 60
Parker Hannifin
Programming Basics 61
Parentheses
Using parentheses, you can group operations in an expression to
change the order in which they are performed.
Operational Order
For example, the expression
4 + 6 / 2
provides the answer 7, and not 5, because division performs before
addition. When a mathematical expression contains operators that
have the same rank, operations are performed left to right. For
example, in the expression
2 + 6 / 3 * 5 - 9
division and multiplication perform before addition and subtraction.
The first operation is 6 / 3; the second operation multiplies the result
2 by 5, which results as 10. In the third operation, add 2 to 10, which
results as 12. In the fourth operation, subtract 9 from 12 to produce
the final answer of 3.
By using parentheses, you can change the order of operations in an
expression. That is, operations in parentheses are performed first,
then operations outside the parentheses. For example, the
expression
(2 + 6 / 3) * 5 - 9
results in an answer of 11, while the expression
(2 + 6 / 3) * (5 - 9)
results in -16 as the answer.
Nested Parentheses
You can also embed parentheses, where operations in the deepest
parentheses are performed first. For example, the expression
((7 + 3) / 2) * 3
contains embedded parentheses. From the example, the first
operation is 7+3, the second operation is 10/2, and the third
operation is 5*3, which results in 15 as the answer.
Examples
The following demonstrate some simple uses of expressions. The
examples assume memory space is allocated for the variables.
Example 1
The following causes axis X to move position to the resulting value of
the expression.
X(P0 + P2 * P30)
Vue de la page 60
1 2 ... 56 57 58 59 60 61 62 63 64 65 66 ... 198 199

Commentaires sur ces manuels

Pas de commentaire