[Flavors] Flavors Technology, Inc.


Paracell Users' Guide

  • Table of Contents
  • Introduction
  • Programming Model
  • Elements of the Language
  • Structure of the Language
  • Elements of Variables
  • Operators
  • Appendices
  • Flavors Home
  • Flavors Product Information
  • PIM/Paracell Presentation
  • PIM Configurations
  • Product Documentation
  • PIM/Paracell Product Summary
  • Paracell User's Guide
  • Application Notes
  • Flavors Staff
  • Flavors Links
  • Flavors Download Page

  • Operators

    An operator is a keyword that denotes an operation. There are four categories of operations: arithmetic, relational, logical, and bitwise operations. Arithmetic operators perform arithmetic calculations to produce a numerical value. Relational operators and logical operators compare values to produce a value, true, false, or NAN (Not A Number). Bitwise operators perform bitwise operations on Machine Integers to produce a numerical value.

    A complete set of operators available in Paracell is listed below. Detailed descriptions of each operator can be found in Appendices A and B. If there is more than one operator, Operator Precedence is used to determine the order of operation.

    Operators available in Paracell by category of operation:

    Arithmetic Logical Bitwise Relational
    + and bitand =
    - or bitor /=
    * not  
    /     >
    abs     >=
    add     >
    divide     <
    max     <=
    min     <
    minus     equal to
    mod     not equal to
    multiply     greater than
    plus     greater than or equal to
    subtract     less than
    times     less than or equal to
          is (are)
          isn't (is not, ain't)

    Due to the dual heritage, many of the operators above have English and computer science counterparts. For example,

      x plus y 
      x + y

    Both of these perform the same operation, but are written in two different ways. The first example is a wordy, but more readable English-like form. The second example is a more succinct, but less readable computer science (or mathematical) form.

    Most operators have the following format.

      (a value or a variable) [operator] (a value or a variable)

    Arithmetic operators also have equivalent Setters and Assigners. Setters perform the associated arithmetic operation on a variable, and have the following format.

      [setter] (a variable) by (a set value)

    The associated arithmetic operation is performed on the (a variable) with (a set value) as the other operand. The by (a set value) part of the format is typically optional, and has a default value of 1. For example,

      Increment x

    is equivalent to

      x = x + 1.

    or

      Set x to x + 1.

    Assigners perform the associated arithmetic operation on a variable, and have the following format.

      [assigner] (a variable or a value) to (a variable).

    The associated arithmetic operation is performed on the (a variable) with (a variable or a value) as the other operand. For example,

      Add 5 to x.

    is equivalent to

      x = x + 5.

    or

      Assign (x + 5) to x.

    The following table lists the equivalent setters and assigners of arithmetic operators.

    Operator Setter Assigner
    [identity] Set Assign
    +, plus Increment Add
    -, minus Decrement Subtract
    *,times Multiply  
    /, divided by Divide  

    Some operators use special formats. These are called .i.Special Functions;, and are listed below. These operators are direct descendants of other computer languages, and do not have equivalent English like format. Detailed description of these functions can be found in Appendix A.

    Special Functions

      abs
      max
      min
      mod


    (Return to top of Page)

    Operator Precedence

     

    Operator precedence describes the order of the operators, or the order of computation. The operator precedence follows the convention we have all learned in elementary school (also known as the Infix Notation). If a sentence contains more than one operator, the rule of Operator Precedence determines the order of computation.

    The Operator Precedence observes the following rules in the order listed.

    1. Carry out operations inside the parentheses. If there is more than one set of parentheses, start from the inner most set.
    2. Evaluate Special Functions (including not).
    3. Carry out multiplications and divisions.
    4. Carry out additions and subtractions.
    5. Carry out any Relational operations. (>,<,>,<,=,)
    6. Carry out any Bitwise operations. (bitand, bitxor, bitor)
    7. Carry out any Logical operations. (and, or)
    8. In the case of a tie, perform computation from left to right.

    The assigned precedence order of operators are listed below.

      x = temp_4 + press_8 * water_level_4

    Because multiplication has precedence over addition, the press_8 * water_level_4 is computed before the addition. Parentheses can change this order. Since operations in parentheses are always carried out first,

      x = (temp_4 + press_8) * water_level_4

    the result of (temp_4 + press_8) is multiplied by water_level_4.

    Special functions, such as the absolute value function (abs), have precedence over multiplications and divisions. For example, in

      x = temp_4 + abs press_8 * water_level_4

    the absolute value of press_8 is computed before the multiplication. If there are nested parentheses, computations in the inner most parentheses are performed first.

    Here is an illustration of the above rules. For this example, if x is -4...

      x = ((1 + 2) * (3 + abs x)) / 7 * 6 + 2.  
      x = ((1 + 2) * (3 + 4)) / 7 * 6 + 2.	// absolute value of -4
      x = (3 * 7) / 7 * 6 + 2.	// inner most parentheses 
      x = 21 / 7 * 6 + 2.	// next parentheses
      x = 3 * 6 + 2. 	// left most division 
      x = 18 + 2.	// multiplication 
      x = 20.	// addition

    The following table lists the operators available in Paracell, and their corresponding precedence.

    Operator Precedence Order
    not 10
    special functions 9
    multiplication 9
    division 9
    addition 8
    subtraction 8
    >,< 7
    >,< 7
    =, 6
    bitand 5
    bitxor 4
    bitor 3
    and 2
    or 1

    In this table, the higher the precedence order number, the higher the precedence. For example,

      x and y > z * q

    is the same as

      x and (y > (z * q))

    multiplication is done first (the z*q), then the relation (y > (z *q)) is evaluated. The result of this inequality (true or false) is then compared to x, for the logical operation AND.


    (Return to top of Page)

    Mixed Type Operations

     

    When operations involve operands of mixed types, the types of values are converted "upwards." Types are converted "downward" only when the result of the operation is in the downward direction from the operands and at the time of the assignment. The upward direction is: Machine Integer to Paracell Number.

    For example, for

      [Paracell Number] = [Paracell Number] an operator [Machine Integer]

    the Machine Integer is converted to a Paracell Number. If the Machine Integer value is out of range of Paracell Number, then the converted Paracell Number will lose its precision. It will become either +RAIL or -RAIL. For example, Machine Integer with value, -3,000,000 becomes -RAIL in Paracell Number. This is because Machine Integers have wider range of numbers than Paracell Numbers.

    In the following example,

      [Machine Integer]  = [Paracell Number] an operator [Machine Integer]

    as in the first example, the operands are converted "upwards." The operand that is a Machine Integer is converted to a Paracell Number. Again, the operation produces a Paracell Number as a result. At the time of the assignment, the result of the operation, a Paracell Number, is then converted to a Machine Integer.


    Next: Keywords Listing, Top: Table of Contents


     

     Flavors Technology, Inc.
    Sunrise Labs
    5 Dartmouth Drive
    Auburn, NH 03032 USA
    Internet: info@flavors.com
    Telephone: 603-644-4500 / Fax: 603-622-9797

    Copyright© 1993-6 by Flavors Technology, Inc. All rights Reserved.