• Main Page
  • Files
  • File List
  • File Members

/Users/garethloy/Musimathics/Musimat1.2/MusimatTutorial/B0110.cpp

Go to the documentation of this file.
00001 #include "MusimatTutorial.h"
00002 MusimatTutorialSection(B0110) {
00003         Print("*** B.1.10 Relations ***");
00004         /*****************************************************************************
00005          
00006          B.1.10 Relations
00007          
00008          Relational operators compare pairs of numeric values. The relational operators are:
00009 
00010                 Operator        Comparison
00011                 <                       less than
00012                 >                       greater than
00013                 ==                      equal
00014                 !=                      not equal
00015                 <=                      less than or equal
00016                 >=                      greater than or equal.
00017          
00018          A relational expression compares two values. If the relationship is False, the value of the
00019          relational expression is 0. If the relationship is True, the value of the relational expression
00020          is 1.
00021          
00022          For example, trivially, the expression 2 < 3 is True, because 2 is less than 3. Therefore,
00023          if we evaluate this expression and print the result, the value 1 will be printed.
00024          *****************************************************************************/
00025 
00026         Print("2 < 3 is ", 2 < 3); // will print 1
00027         Print("2 > 3 is ", 2 > 3); // will print 0
00028 
00029         /*****************************************************************************
00030          Because "=" has already been given the meaning of assignment, we must choose another way to 
00031          express equality, which we do by putting two equals signs together: "==". For example, the expres-
00032          sion x == y is True if x and y have the same value.
00033          
00034          Inequality is expressed by !=, so for example, x != y is True if x and y have different values.
00035          *****************************************************************************/
00036         
00037         Integer x = 2;
00038         Integer y = 3;
00039         Print("x == y is ", x == y); // will print 0
00040         Print("x != y is ", x != y); // will print 1
00041         
00042         /*****************************************************************************
00043          Musimat defines True == 1 and False == 0.
00044          *****************************************************************************/
00045         
00046         Print("True is ", True);
00047         Print("False is ", False);
00048         
00049         /*****************************************************************************
00050          Besides Integer and Real, there is also a data type called Bool that can store
00051          the truth value of a relational expression.
00052          *****************************************************************************/
00053         
00054         Bool t = True;
00055         Bool f = False;
00056         Print("t == True ", t == True); // prints 1
00057         Print("f == False ", f == False); // prints 1
00058         
00059 }
00060 
00062 /* $Revision: 1.2 $ $Date: 2006/09/05 06:32:25 $ $Author: dgl $ $Name:  $ $Id: B0110.cpp,v 1.2 2006/09/05 06:32:25 dgl Exp $ */
00063 // The Musimat Tutorial � 2006 Gareth Loy
00064 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" � 2006 Gareth Loy 
00065 // and published exclusively by The MIT Press.
00066 // This program is released WITHOUT ANY WARRANTY; without even the implied 
00067 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00068 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
00069 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
00070 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
00071 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
00072 // The Musimat website:                 http://www.musimat.com/
00073 // This program is released under the terms of the GNU General Public License
00074 // available here:                      http://www.gnu.org/licenses/gpl.txt
00075 

Generated on Fri Nov 26 2010 16:18:25 for Musimat Tutorial by  doxygen 1.7.2