C:/Musimathics_local/Musimat/MusimatTutorial/B0112.cpp File Reference

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0112)


Function Documentation

MusimatTutorialSection ( B0112   ) 

Definition at line 2 of file B0112.cpp.

00002                               {
00003 Print("*** B.1.12 Operator Precedence and Associativity ***");
00004 /*****************************************************************************
00005 
00006 B.1.12 Operator Precedence and Associativity
00007 
00008 In the expression a * x + b * y, what is the order in which the operations are carried out? By 
00009 the standard rules of mathematics, we should first form the products a*x and b*y, then 
00010 sum the result. So multiplication has higher precedence than addition. The natural precedence of 
00011 operations can be overridden by the use of parentheses. For example, a * (x + b) * y forces the 
00012 summation to occur before the multiplications.
00013 
00014 In the expression a + b + c, we first add a to b, then add the result to c, so the associativity 
00015 of addition is left to right. We could express left-to-right associativity explicitly like this: 
00016 (((a) + b) + c).
00017 
00018 The rules of precedence and associativity in programming languages can be complicated, but 
00019 the programming examples in this section use the following simplified rules.
00020 
00021 Expressions are evaluated from left to right, except
00022 
00023 o Multiplications and divisions are performed before additions and subtractions.
00024 
00025 o All arithmetic operations (+, –, *, /) are performed before logical operations (And, Or, 
00026   ==, <, >).
00027 
00028 o Parentheses override the above precedence rules.
00029 
00030 For details, see section B.3.
00031 
00032 *****************************************************************************/
00033 }}


Generated on Fri Sep 8 00:53:00 2006 for MusimatLib by  doxygen 1.4.7