The limited dynamic range of small integers can be used to simplify some expressions, even if the value of the small integer is not known.


Each of the expressions in the code fragments below can be replaced with the value zero (on systems that define short to have 16 bits).

unsigned short int s;

(s >> 20)      /* all bits of precision have been shifted out, thus 0 */
(s > 0x10000)  /* 16 bit value can't be greater than 17 bit, thus 0 */
(s == -1)      /* can't be negative, thus 0 */


This type of expression may indicate an error in the program, and some compilers emit warnings for some of these expressions (e.g. unsigned short compared to a negative constant).

Programmers generally don't write these expressions directly. However, these expressions can occur after macro expansion, or after other optimizations.