Versions Compared

Key

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

...

This can lead to programming errors when decimal values are mistakenly specified as octal constants.

Noncompliant

...

Code Example

In this noncompliant code example, a decimal constant is mistakenly prefaced with zeros so that all the constants are a fixed length.

...

Wiki Markup
Although it may appear that that {{i_array\[2]\}} is assigned the decimal value 42, it is actually assigned the decimal value 34.

Compliant

...

Code Example

To avoid using wrong values and make the code more readable, don't preface constants with zeroes if the value is meant to be decimal.

...

Wiki Markup
\[[ISO/IEC 9899:1999|cplusplus:AA. C References#ISO/IEC 9899-1999]\] Section 6.4.4.1  "Integer constants"
\[MISRA 042004\] Section 6.7 Rule 7.1

...

      02. Declarations and Initialization (DCL)      DCL19-C. Use as minimal a scope as possible for all variables and functions