[previous] MISRA-C:2004  Rule  3.3:  (Advisory) [next] The implementation of integer division in the chosen compiler should be determined, documented and taken into account.
Potentially an ISO compliant compiler can do one of two things when dividing two signed integers, one of which is positive and one negative. Firstly it may round up, with a negative remainder (e.g. -5/3 = -1 remainder -2), or secondly it may round down with a positive remainder (e.g. -5/3 = -2 remainder +1). It is important to determine which of these is implemented by the compiler and to document it for programmers, especially if it is the second (perhaps less intuitive) implementation.

Example Code:


#include "misra.h"
#include "m2cmex.h"


extern S16 test_0303( void )
{
   return 0;
}


No QAC messages cover this rule.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents