00001 #include "MusimatTutorial.h" 00002 MusimatTutorialSection(B0108) { 00003 Print("*** B.1.8 Operators and Operands ***"); 00004 /***************************************************************************** 00005 00006 B.1.8 Operators and Operands 00007 00008 The symbols + and - are operators, and the data they act upon are operands. Most operators take 00009 two operands, and the operator lies between the operands, for example, a + b, and c / d. Such 00010 operators are called binary infix, meaning that the operator lies between two operands. In its binary 00011 infix form, the symbol "-" means subtraction, for example, a - b. The unary prefix "-" operator 00012 comes before the expression it negates, for example, -3. 00013 *****************************************************************************/ 00014 00015 Print("2 + 2 = ", 2 + 2); 00016 Print("-3 = ", -3); 00017 00018 /***************************************************************************** 00019 00020 Multiplication in mathematics is typically expressed by the concatenation of variables, so for 00021 instance in standard mathematics parlance, "at" means the product of variables a and t. 00022 But this can be ambiguous, because at could 00023 also refer to the English word "at". 00024 To avoid ambiguity, the infix operator "*" indicates multiplication, 00025 so the product of m times n is written m * n. 00026 00027 *****************************************************************************/ 00028 00029 Integer m = 2; 00030 Integer n = 3; 00031 Print("m * n = ", m * n); 00032 00033 } 00034 00036 /* $Revision: 1.2 $ $Date: 2006/09/05 06:32:25 $ $Author: dgl $ $Name: $ $Id: B0108.cpp,v 1.2 2006/09/05 06:32:25 dgl Exp $ */ 00037 // The Musimat Tutorial © 2006 Gareth Loy 00038 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy 00039 // and published exclusively by The MIT Press. 00040 // This program is released WITHOUT ANY WARRANTY; without even the implied 00041 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00042 // For information on usage and redistribution, and for a DISCLAIMER OF ALL 00043 // WARRANTIES, see the file, "LICENSE.txt," in this distribution. 00044 // "Musimathics" is available here: http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916 00045 // Gareth Loy's Musimathics website: http://www.musimathics.com/ 00046 // The Musimat website: http://www.musimat.com/ 00047 // This program is released under the terms of the GNU General Public License 00048 // available here: http://www.gnu.org/licenses/gpl.txt 00049