COHERENT manpages

This page displays the COHERENT manpage for operator [Definition].

List of available manpages
Index


operator -- Definition

An operator  is a function that  is built into the  C language.  It usually
relates one operand to another.  For example, the statement

    1+2

relates the  operands 1  and 2  through the operation  of addition;  on the
other hand, the statement

    A>B

relates the  operands A and  B logically, by  asserting that the  former is
greater than the latter; whereas

    A=B

relates the  operands A and B  by assigning the value of  the latter to the
former.  The following is a table of the C operators:

    *       Multiplication
    /       Division
    %       Remainder
    +       Addition
    -       Subtraction

    <    Less than
    <=   Less than or equal to
    >    Greater than
    >=   Greater than or equal to

    &&Logical AND
    !=      Inequality
    !       Logical negation
    | |     logical OR

    &   Bitwise AND
    ^       Bitwise exclusive OR
    ~       Bitwise complement
    |       Bitwise inclusive OR
    <<Bitwise shift left
    >>Bitwise shift right

    =       Assign
    +=      Increment and assign
    -=      Decrement and assign
    *=      Multiply and assign
    /=      Divide and assign
    %=      Modulus and assign
    ++      Increment
    --      Decrement
    ==      Equivalence
    &=  Bitwise AND and assign
    ^=      Bitwise exclusive OR and assign
    |=      Bitwise inclusive OR and assign
    <<=Bitwise shift left and assign
    >>=Bitwise shift right and assign

    *       Indirection
    &   Render an address
    ()      Function indicator
    []      Array indicator
    ->   Structure pointer
    .       Structure member
    ? :     Conditional expression

    sizeof  size of an object

Precedence

Precedence  refers to  the  order in  which  C executes  operators.  The  C
languages assigns  a level of  precedence to each  operator.  Operators are
executed in the order of their precedence level, from highest to lowest.

The  following table  summarizes the  precedence of  C operators.   The are
listed in descending order of  precedence: those listed higher in the table
are executed before those lower in the table.  Operators listed on the same
line have  the same level of precedence,  and the implementation determines
the  order  in which  they  are executed.   If  you use  two  or more  such
operators in the  same expression, you would be wise  to use parentheses to
indicate exactly the order in which you want the operators executed.

    Operator                          Associativity

    ()   []   ->   .               Left to right

    !  ~  ++  --  -  (type)  *  &  sizeofRight to left

    *  /  %                           Left to right

    +  -                              Left to right

    <<  >>                Left to right

    <  <=  >  >=          Left to right

    ==  !=                            Left to right

    &                             Left to right

    ^                                 Left to right

    |                                 Left to right

    &&                        Left to right

    ||                                Left to right

    ?:                                Right to left

    =  +=  -=  *=  /=  %=             Right to left

    ,                                 Left to right

You  can always  determine precedence  in an  expression by  enclosing sub-
expressions  within   parentheses:  the  expression   enclosed  within  the
innermost parentheses is always executed first.

See Also

Programming COHERENT,
sizeof
ANSI Standard, §6.1, §6.3