Rule A2-13-5 (advisory, implementation, automated)

Hexadecimal constants should be upper case.

Rationale

Using upper case literals for hexadecimal constants makes the source code consistent in this matter and removes a potential developer confusion.

Example

//% $Id: A2-13-5.cpp 305629 2018-01-29 13:29:25Z piotr.serwa $

#include <cstdint>

int main(void)
{
std::int16_t a = 0x0f0f; //non-compliant
std::int16_t b = 0x0f0F; //non-compliant
std::int16_t c = 0x0F0F; //compliant

return 0;

}

See also

JSF December 2005 [8]: AV Rule 150: Hexadecimal constants will be represented using all uppercase letters. Rule M2-13-2 (required, architecture / design / implementation,automated) Octal constants (other than zero) and octal escape sequences (other than ā€œ\0ā€ ) shall not be used. See MISRA C++ 2008 [7] Rule M2-13-3 (required, architecture / design / implementation,automated) A ā€œUā€ suffix shall be applied to all octal or hexadecimal integer literals of unsigned type. See MISRA C++ 2008 [7]

Rule M2-13-4 (required, architecture / design / implementation,automated) Literal suffixes shall be upper case. See MISRA C++ 2008 [7]