Immediate data

  • Thread starter those who know me have no need of my name
  • Start date
T

those who know me have no need of my name

in comp.lang.c i read:
Which types are immediates by default?

what are these `immediates' of which you speak? i see constants below.
It would be logical if they were of the largest compatible type..

they are the narrowest sensible type. (char, short and float are not in
this set.)
1, int
correct.

FFFFFFFF, unsigned int

this isn't a valid hexadecimal constant, you forgot the 0x prefix. given
that as an assumed correction...

it depends on the width of the implementation's int's -- it can be int,
unsigned int, long or unsigned long. i.e., you may think that 32 bit int's
are universal -- they are not; plenty of platforms exist where int is 16 or
64 bits (or other, seemingly stranger values). the most common types today
are unsigned int or unsigned long.
'a', int
1.2, double
1e300, double

correct.
 
J

Jack Klein

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.
 
M

Martin Johansen

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,819
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top