| NWN2 Scripting. |
Simulation Training. Introduction Home First Program Seeing Results Variables and Data Types Comments Functions Data Conversion Random Numbers Concatenation Arithmetic Operators Compound Assignments One More or Less Precedence Relational Operators The Open Branch The Closed Branch Logical AND Logical OR Compound Statements ELSE If Switch Case The ? Operator The for Loop The while Loop The do while Loop Introduction to Functions Passing Values Passing Multiple Values Multiple Functions Simplifying Functions TRUE/fALSE Conditions Return Values Setting Global Variables Getting Global Variables Setting Local Variables Getting Local Variables WayPoints Introduction Static Waypoint Sets Dynamic Waypoint Sets Dynamic WP Cycles Input Output |
PrecedencePrecedence of operations is simply the order in which arithmetic operations are performed.
Examples The following examples illustrate precedence of operations:
X = 6 + 12/6 * 2 - 1 Original Problem Solution: X = 6 + 2 * 2 - 1 (Division precedence) X = 6 + 4 - 1 (Multiplication precedence) X = 9 (Operations from left to right)
A = (6 +12)/6 * 2 - 1 Original Problem Solution: X = 18/6 * 2 - 1 (Work inside parentheses done first) X = 3 * 2 - 1 (Operations from left to right) x = 6 - 1 (Multiplication precedence) X = 8
Y = 6 +12/6 * (2-1) Original Problem Solution: Y = 6 + 12/6 * 1 (Work inside parentheses done first) Y = 6 + 2 * 1 (Operations from let to right) Y = 6 + 2 (Multiplication Precedence) Y = 8
Z = 6 + 12(6 * 2) - 1 Original Problem Solution: Z = 6 + 12/12 - 1 (Work inside parentheses done first) Z = 6 + 1 - 1 (Division Precedence) Z = 6 (Operations from left to right)
C++ uses the same precedence of operations as illustrated here.
|
|