Most integer operations can result in overflow if the resulting value cannot be represented by the underlying representation of the integer. The following table indicates which operators can result in overflow:
Operator | Overflow |
| Operator | Overflow |
| Operator | Overflow |
| Operator | Overflow |
---|---|---|---|---|---|---|---|---|---|---|
+ | yes |
| -= | yes |
| * << | yes |
| / < | yes no |
% - | yes | + | + *= | yes |
| >> - | yes |
| > = | no |
+= * | yes |
| / -= | yes |
| & | no |
| > *= | yes no |
/ = | yes |
| %= | yes |
| | | no << | yes | >> <= | no |
% | yes | |||||||||
&= | no | |||||||||
| << | yes |
| ^ |= | no |
| = ^= | no << | ||
++ | yes |
| >>= | yes |
| ~ & | no | | | != | no |
- | yes ^ | no | ~ &= | no |
| ! | no un |
| && + | no |
un - | yes | |||||||||
= | no |
| |= < | no | > | un + | no > |
| || = | no |
< += | no yes | |||||||||
== | no | |||||||||
| ^ != | no | && | no un - | || yes | no | ?: | no |
Addition
Addition in C is between two operands of arithmetic type, or between a pointer to an object type and an integer type. (Incrementing is equivalent to adding one.)
...