Programming in C

(Barry) #1
5.0 Expressions 445

The usual arithmetic conversions are performed on aand b(see Section 5.17).The first
four relational tests are only meaningful for pointers if they both point into the same
array or to members of the same structure or union.The type of the result in each case
is int.

5.6 Bitwise Operators


Given that
i, j, n are expressions of any integer data type;
then the expression
i & j performs a bitwise AND of iand j;
i | j performs a bitwise OR of iand j;
i ^ j performs a bitwise XOR of iand j;
~i takes the ones complement of i;
i << n shifts ito the left nbits;
i >> n shifts ito the right nbits.
The usual arithmetic conversions are performed on the operands, except with <<and >>,
in which case just integral promotion is performed on each operand (see Section 5.17).
If the shift count is negative or is greater than or equal to the number of bits contained
in the object being shifted, the result of the shift is undefined. On some machines, a
right shift is arithmetic (sign fill) and on others logical (zero fill).The type of the result
of a shift operation is that of the promoted left operand.

5.7 Increment and Decrement Operators


Given that
lv is a modifiable lvalueexpression, whose type is not qualified as
const;
then the expression
++lv increments lvand then uses its value as the value of the expression;
lv++ uses lvas the value of the expression and then increments lv;
--lv decrements lvand then uses its value as the value of the expression;
lv-- uses lvas the value of the expression and then decrements lv.
Section 5.15 describes these operations on pointers.

20 0672326663 AppA 6/10/04 2:01 PM Page 445

Free download pdf