x % 2^n == x & (2^n - 1) 

This formula does not work if x is negative in languages where % uses the sign of the dividend. How can the C compilers use it? Do they use it only when they can prove that x is positive or only in earlier revisions than C99?