Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Integral promotion.
#1
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.
<t></t>
Reply
#2
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
Reply
#3
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
<r>Applications conformance testing: <URL url="http://www.knosof.co.uk/cbook">http://www.knosof.co.uk/cbook</URL></r>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)