Versions Compared

Key

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

Wiki Markup
In C89 (and historical K&R [implementations|BB. Definitions#implementation]), the meaning of the remainder operator for negative operands was [implementation defined|BB. Definitions#implementation defined behavior]. This was changed in the C99 standard \[[ISO/IEC 9899-1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\].

Because not all C compilers are strictly C99 conforming, you cannot rely on the behavior of the % operator if you need to run on a wide range of platforms with many different compilers.

...

Wiki Markup
\[[Beebe 05|AA. References#BeebeBibliography#Beebe 05]\]
\[[ISO/IEC 9899-1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\] Section 6.5.5, "Multiplicative operators"
\[[Microsoft 07|AA. References#MicrosoftBibliography#Microsoft 07]\] [C Multiplicative Operators|http://msdn2.microsoft.com/en-us/library/efa0csed(VS.80).aspx]
\[[MITRE 07|AA. References#MITREBibliography#MITRE 07]\] [CWE ID 682|http://cwe.mitre.org/data/definitions/682.html], "Incorrect Calculation," and [CWE ID 129|http://cwe.mitre.org/data/definitions/129.html], "Unchecked Array Indexing"
\[[Sun 05|AA. References#SunBibliography#Sun 05]\] [Appendix E, "Implementation-Defined ISO/IEC C90 Behavior"|http://docs.sun.com/source/819-3688/c90.implementation.app.html]

...