Functions

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

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0110)

Function Documentation

MusimatTutorialSection ( B0110   )

Definition at line 2 of file B0110.cpp.

References x, and y.

                              {
        Print("*** B.1.10 Relations ***");
        /*****************************************************************************
         
         B.1.10 Relations
         
         Relational operators compare pairs of numeric values. The relational operators are:

                Operator        Comparison
                <                       less than
                >                       greater than
                ==                      equal
                !=                      not equal
                <=                      less than or equal
                >=                      greater than or equal.
         
         A relational expression compares two values. If the relationship is False, the value of the
         relational expression is 0. If the relationship is True, the value of the relational expression
         is 1.
         
         For example, trivially, the expression 2 < 3 is True, because 2 is less than 3. Therefore,
         if we evaluate this expression and print the result, the value 1 will be printed.
         *****************************************************************************/

        Print("2 < 3 is ", 2 < 3); // will print 1
        Print("2 > 3 is ", 2 > 3); // will print 0

        /*****************************************************************************
         Because "=" has already been given the meaning of assignment, we must choose another way to 
         express equality, which we do by putting two equals signs together: "==". For example, the expres-
         sion x == y is True if x and y have the same value.
         
         Inequality is expressed by !=, so for example, x != y is True if x and y have different values.
         *****************************************************************************/
        
        Integer x = 2;
        Integer y = 3;
        Print("x == y is ", x == y); // will print 0
        Print("x != y is ", x != y); // will print 1
        
        /*****************************************************************************
         Musimat defines True == 1 and False == 0.
         *****************************************************************************/
        
        Print("True is ", True);
        Print("False is ", False);
        
        /*****************************************************************************
         Besides Integer and Real, there is also a data type called Bool that can store
         the truth value of a relational expression.
         *****************************************************************************/
        
        Bool t = True;
        Bool f = False;
        Print("t == True ", t == True); // prints 1
        Print("f == False ", f == False); // prints 1
        
}