Dynamic Descriptions - Operators

       Continents Main page        Table of Contents        Previous Topic        Next Topic


Numeric Operators
  In maths expressions, there are a number of operators.  Some of these are
  comparisons, and will result in a conditional expression (one that must be
  terminated with "|").

  o +, -, *, /.  The basic arithmetic operators work as normal.  "-" can also
    be the operator for negation (-4 is negative 4, obviously).
    - eg: [2+2]{result} => prints "4".

  o == checks for equality.  It is a conditional operator.
    - eg: [2==2]|{result} => prints "1" (which is "true").

  o != checks for inequality.  It is a conditional operator.
    - eg: [2!=2]|{result} => prints "0" (which is "false").

  o <, >.  Less than and Greater than.  Conditional
    - eg: [2>2]|{result} => prints "0".

  o <=, >=.  Less-than-or-equal-to and Greater-than-or-equal-to.  Conditional.
    - eg: [2>=2]|{result} => prints "1".

  o &&.  Logical "And".  Conditional.  The truth table for And is:

    X && Y == Z
    T    T    T
    T    F    F
    F    T    F
    F    F    F

    So if X and Y are both true, then X && Y == true.  Otherwise false.

  o ||.  Logical "Or".  Conditional.  The truth table for Or is:

    X || Y == Z
    T    T    T
    T    F    T
    F    T    T
    F    F    F

    So if either X or Y is true, then X || Y == true.  Otherwise false.

  o Other truth operators (exclusive or, implies) can be added if so desired.

  o (, ). Parentheses.  These are used to denote how a calculation is
    performed.  They are very important in complex calculations, since the
    parser has no knowledge of order of precedence of operators.

  Something to note is that, with && and ||, it is imperative that large
  amounts of brackets are used because of the way it is designed, so:

  [{true}&&{false}=={true}]|{result}

  actually gives the error "Invalid position of close bracket".  The correct
  code is given by adding parentheses:

  [({true}&&{false})=={true}]|{result}

  which correctly prints "0".

       Continents Main page        Table of Contents        Previous Topic        Next Topic