Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In C89 (and historical K&R implementations), the meaning of the remainder operator for negative arguments was implementation-defined, but was fixed in the C99 Standard.

...

The C99 definition of % operator implies the following behavior:

Code Block
 17 %  3  ->  2
 17 % -3  ->  2
-17 %  3  -> -2
-17 % -3  -> -2

...