05-12-2014, 09:19 AM
The following examples assumes the following type ranges:
So for example 2147483647 (2**31-1) will have an essential type of essentially signed int, but 2147483648 (2**31) will have an essential type of essentially signed long.
2**X is used to represent 2 to the power X
- char - 8 bits
short - 16 bits
int - 32 bits
long - 64 bits
Code:
| Constant value range | Essential Type
| -2**7 .. 2**7-1 | essentially signed char |
| -2**15 .. -2**7-1 and 2**7 .. 2**15-1 | essentially signed short |
| -2**31 .. -2**15-1 and 2**15 .. 2**31-1 | essentially signed int |
| -2**63 .. -2**31-1 and 2**31 .. 2**63-1 | essentially signed long |
2**X is used to represent 2 to the power X
Posted by and on behalf of the MISRA C Working Group