On Tue, 18 May 2004 02:25:56 -0700, Martin Johansen <mf**@online.no>
wrote in comp.lang.c:
Hi group
Which types are immediates by default?
It would be logical if they were of the largest compatible type..
Any way, take these three examples, followed by my guess:
1, int
FFFFFFFF, unsigned int
'a', int
1.2, double
1e300, double
Thank you!
From the examples in your post, I assume what you are calling
"immediates" is what the C standard just calls "constants".
The answer depends on both the way the constant is written and whether
or not any suffixes are used.
Decimal integer constants have the first type in which the value is
representable out of int, long int, long long int. Octal or
hexadecimal constants go through int, unsigned int, long, unsigned
long, long long, unsigned long long.
FFFFFFFF is an identifier or macro, not a constant, although
0xFFFFFFFF is a constant. It might be signed int, unsigned int,
signed long, or unsigned long, depending on the implementation's
representation of these types.
All single character constants have type int.
All floating point constants have type double unless they are suffixed
with one of 'f', 'F', which makes them floats, or 'l' or 'L' which
makes them long doubles.
Buying a decent C reference book might be in order.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html