MISRA Discussion Forums

Full Version: Integral promotion.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have some doubt about the integral promotion whether how integral promotion's rule perform with the unsuffixed constant (hexadecimal).
Example:

16bit ECU
0xffff -----> Will it promote to \"int\" or \"unsigned int\"?
0xffffffff -----> Will it promote to \"int\" or \"unsigned int\"?

32bit ECU
0xffff -----> Will it promote to \"int\" or \"unsigned int\"?
0xffffffff -----> Will it promote to \"int\" or \"unsigned int\"?

Who know how does it perform with hexadecimal.
Please kindly give me the answer.

Thanks in advance,
Warawut.
The type of an unsifixed hexadecimal constant is the first of the following list in which its value can be represented:

int
unsigned int
long
unsigned long

then, for 16 bits µC (int=16bits):
0xffff => unsigned int
0xffffffff => unsigned long

and for 32 bits µC (int=32bits):
0xffff => int
0xffffffff => unsigned int
Those wanting to search the C Standard, looking for appropriate wording for a problem, might like to use http://c0x.coding-guidelines.com, which as been indexed by Google. Please note that the text is based on C99, not C90.

The wording appropriate to this question can be found in:
http://c0x.coding-guidelines.com/6.3.1.1.html (at least it would be if I had not manged to mangle the formatting of tables; fixed real-soon-now).

Those who regularly use the C Standard + Firefox can make use of the following handy plug-in:
http://mycroft.mozdev.org/download.html?...orm=Search