KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Arithmetic Procedence
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: August 1, 1998
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Precedence refers to the order in which operations occur. In algebra, a multiplication operation has precedence over an addition operation. This means that the multiplication is carried out before the addition, even if the addition comes first in the expression (i.e., 1+2*3=1+6=7, not 3*3=9). Standard algebraic precedence follows this order: exponentiation,multiplication and division, and addition and subtraction, or ^, * and ÷, + and -. Parenthetical operators are used to "promote" operations to a higher level of precedence than normal (i.e., 2*(3+4)=2+7=14, not 6*4=24). 4th Dimension's precedence is somewhat different. In 4D, arithmetic and algebraic operations ALWAYS evaluate in order from left to right, as long as parenthetical operators are not involved. This means that 1+2*3 in 4D is evaluated from left to right, so the addition occurs first, and the result is then multiplied by three. In the previous paragraph, the expression evaluates to 7 under algebraic precedence, but in 4D, the expression evaluates to 9. The second example uses parenthetical operators and evaluates to 14 in both orders of precedence. It is critical to remember that in 4D, arithmetic precedence is different from that traditionally taught in math and algebra classes. No precedence, which is another name for left to right precedence, is as logically valid as algebraic precedence, and is simpler than algebraic precedence, since it has fewer rules.