Integral promotion. - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: General Questions (https://forum.misra.org.uk/forumdisplay.php?fid=27) +--- Thread: Integral promotion. (/showthread.php?tid=223) |
Integral promotion. - warawut - 01-03-2006 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. - lv - 01-03-2006 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 Searching the C(99) Standard - derek_farn - 03-03-2006 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?name=coding-guidelines&submitform=Search |