UbiQ Scenario Manager User Manual
46
4.4
Expressions and Assignments
This section describes how to form expressions and to assign values in the C lan-
guage. Constants, identifiers, strings, and function calls are all operands that are
manipulated in expressions. The C language has all the usual language operators.
This section covers those operators as well as operators that are unique to C. The
topics discussed include:
Operators
Operator precedence
4.4.1
Operators
There are three types of operators. A unary expression consists of a unary operator
prepended to an operand. The expression can be either the name of a variable or a
cast expression. If the expression is a cast expression, it must be enclosed in paren-
theses. A binary expression consists of two operands joined by a binary operator. A
ternary expression consists of three operands joined by the conditional-expression
operator.
C includes the following unary operators:
Symbol Name
-
Negation operators
+
Unary plus operator
Binary operators associate from left to right. C provides the following binary opera-
tors:
Symbol Name
* / %
Multiplicative operators
+ -
Additive operators
< > <= >= == != Relational operators
& |
Bitwise operators
&& ||
Logical operators
<< >>
Bit-Shift operators
The conditional-expression operator has lower precedence than binary expressions
and differs from them in being right associative.
Expressions with operators also include assignment expressions, which use unary or
binary assignment operators. The binary assignment operators are the simple-
assignment operator (=) and the compound-assignment operators. Each compound-
assignment operator is a combination of another binary operator with the simple-
assignment operator.
4.4.2
Operator precedence
The precedence and associativity of C operators affect the grouping and evaluation
of operands in expressions. An operator’s precedence is meaningful only if other
operators with higher or lower precedence are present. Expressions with higher-pre-
cedence operators are evaluated first.
Following table summarizes the precedence and associativity (the order in which the
operands are evaluated) of C operators, listing them in order of precedence from
highest to lowest. Where several operators appear together, they have equal prece-
dence and are evaluated according to their associativity. The operators in the table
are described in the sections beginning with Postfix Operators. The rest of this sec-
tion gives general information about precedence and associativity.
Summary of Contents for UbiQ
Page 1: ...User Manual UbiQ Scenario Manager User Manual V1 03...
Page 4: ...UbiQ Scenario Manager User Manual iv...
Page 7: ...Chapter 1 1 Introduction...
Page 13: ...Chapter 2 2 Getting Started...
Page 37: ...Chapter 3 3 Tutorials...
Page 47: ...Chapter 4 4 Basic of Smart C Script Language...
Page 62: ...UbiQ Scenario Manager User Manual 56...