



    ________________________________________________________________________
                                 Chapter 1: What's Really Happening   63
    ________________________________________________________________________


    CHAPTER EIGHT:  NUMERIC OPERATORS

    In PADtalk, operators are used to form expressions. There are operators
    to manipulate numbers, text, and Boolean values. The following
    expression involves all three:

    if (5 + i > 56) and (field 1 = "Lawyer") then...

    Each operator requires two operands of the same type. For example, (5+6)
    is legal, whereas (5 + "this is text") is not legal. However, since
    HyperPAD treats all numbers as text, the text operators work on both
    text and numbers. For example:

    expression:          yields:
    --------------------------------
    5 + 6                11
    "this" & "that"      thisthat
    "this" & 5           this5
    56 && 1              56 1
    "this" <> "that"     true

    The comparison operators work with both text and numeric arguments. For
    example, 5 > 6 returns false, as does "that" > "this". For text
    comparisons, the text operands are compared without regard to case and
    the argument lowest alphabetically will have the lower value.

    The following section describes all of the PADtalk operators:


    ( ) (PARENTHESES)

    Affect the way operands are grouped in expressions. Expressions enclosed
    in parentheses are evaluated first.


    - (UNARY MINUS)

    Produces the negation of the number to its right.


    NOT (LOGICAL NOT)

    Returns false if the result following is true, and true if the
    expression is false.


    ^ (EXPONENTIATION)

    Returns the number on the left raised to the power of the number on its
    right.



    ________________________________________________________________________
                                 Chapter 1: What's Really Happening   64
    ________________________________________________________________________


    / (DIVIDE)

    Returns the number on the left divided by the number on the right.


    * (MULTIPLICATION)

    Returns the number on the left multiplied by the number on the right.


    MOD (MODULE)

    Returns the remainder of the division of the number on the left by the
    number on the right. For example:

    5 mod 3;
    5/3 returns 1 remainder 2, so 5 mod 3 returns 2.


    DIV (DIVIDE AND TRUNCATE)

    Returns the whole part of the division of the number on the left by the
    number on the right. For example:

    5 div 3;
    5/3 = 1.666667; truncating the decimal portion, 5 div 3 returns 1.


    + (ADDITION)

    Returns the number on the left added to the number on the right.


    - (SUBTRACT)

    Returns the number on the left subtracted from the number on the right.


    & (CONCATENATION)

    Returns the argument on the right appended to the argument on the left.
    For example:

    expression:       returns:
    ----------------------------
    1 & 4             14
    56 & "hello"      56hello
    6 & (6=7)         6false
    "this" & "that"   thisthat



    ________________________________________________________________________
                                 Chapter 1: What's Really Happening   65
    ________________________________________________________________________


    && (CONCATENATION WITH SPACE)

    Returns the argument on the right appended to the argument on the left,
    with a space in between them. For example:

    expression:           returns:
    ---------------------------------
    1 && 4                1 4
    56 && "hello"         56 hello
    6 && (6=7)            6 false
    "this" && "that"      this that


    > (GREATER THAN)

    Returns true if the expression on the left is greater than the
    expression on the right. This operator works with both numeric and text
    quantities.


    < (LESS THAN)

    Returns true if the expression on the left is less than the expression
    on the right. This operator works with both numeric and text quantities.


    >= (GREATER THAN OR EQUAL TO)

    Returns true if the expression on the left is greater than or equal to
    the expression on the right.


    <= (LESS THAN OR EQUAL TO)

    Returns true if the expression on the left is less than or equal to the
    expression on the right.


    IS IN

    Returns true if the argument on the left is found in the argument on the
    right. For example:

    expression:                  returns:
    --------------------------------------
    5 is in 5678                 true
    "there" is in "hello there"  true
    "i" is in "hello"            false



    ________________________________________________________________________
                                 Chapter 1: What's Really Happening   66
    ________________________________________________________________________


    IS NOT IN

    Returns true if the argument on the left is not found in the argument on
    the right. For example:

    expression:                    returns:
    ----------------------------------------
    5 is not in 5678               false
    "it" is not in "hello there"   true

    CONTAINS

    Returns true if the argument on the right is found in the argument on
    the left. For example:

    expression:                     returns:
    ------------------------------------------
    "hello there" contains "lo"     true
    67.54 contains 7                true
    "what's up" contains 7          false


    = (EQUAL)

    Returns true if the left and right arguments are the same.
    The arguments can be textual, numeric, or Boolean.


    <> (NOT EQUAL)

    Returns true if the left and right arguments are not the same. The
    arguments can be textual, numeric, or Boolean.


    IS

    Same as =


    IS NOT

    Same as <>


    AND (LOGICAL AND)

    Returns true if both the left and right arguments are true.


    OR (LOGICAL OR)

    Returns true if either the left or right arguments are true.



    ________________________________________________________________________
                                 Chapter 1: What's Really Happening   67
    ________________________________________________________________________


    OPERATOR PRECEDENCE

    Precedence refers to which mathematical operations are performed first
    when evaluating expressions. Operators with the highest precedence are
    evaluated first.

    The following table shows the precedence of the PADtalk operators.
    Operators of equal precedence appear on the same line, separated by a
    comma. Parentheses alter the order of expression evaluation. Operators
    that require two operands (like plus, minus, etc...) are evaluated left
    to right. Exponentiation is evaluated right to left.

    Order:         Operator(s):
    ------------------------------------------------
    1              ()

    2              -, not

    3              ^

    4              /, *, mod, div

    5              +, -

    6              &, &&

    7              >, >=, <, <=, is in, is not in, contains

    8              =, <>, is, is not

    9              and

    10             or