6.5.3.3 Unary arithmetic operators

Previous Table of Contents "New C Standard" commentary

1101 The operand of the unary + or - operator shall have arithmetic type;

1102 of the ~ operator, integer type;

1103 of the ! operator, scalar type.

1104 The result of the unary + operator is the value of its (promoted) operand.

1105 The integer promotions are performed on the operand, and the result has the promoted type.

1106 The result of the unary - operator is the negative of its (promoted) operand.

1107 The integer promotions are performed on the operand, and the result has the promoted type.

1108 The result of the ~ operator is the bitwise complement of its (promoted) operand (that is, each bit in the result is set if and only if the corresponding bit in the converted operand is not set).

1109 The integer promotions are performed on the operand, and the result has the promoted type.

1110 If the promoted type is an unsigned type, the expression ~E is equivalent to the maximum value representable in that type minus E.

1111 The result of the logical negation operator ! is 0 if the value of its operand compares unequal to 0, 1 if the value of its operand compares equal to 0.

1112 The result has type int.

1113 The expression !E is equivalent to (0==E).

1114 84) Thus, &*E is equivalent to E (even if E is a null pointer), and &(E1[E2]) to ((E1)+(E2)).

1115 It is always true that if E is a function designator or an lvalue that is a valid operand of the unary & operator, *&E is a function designator or an lvalue equal to E.

1116 If *P is an lvalue and T is the name of an object pointer type, *(T)P is an lvalue that has a type compatible with that to which T points.

1117 Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime.

Next

Created at: 2008-01-30 02:39:42 The text from WG14/N1256 is copyright © ISO