Integral constants
As with expressions,
the rules for the types of certain integral constants have changed.
Previously, an unsuffixed decimal constant had type
int only if its value fit in an int
and an unsuffixed octal or hexadecimal constant had type
int only if its value fit in an unsigned int.
Otherwise, an integral constant had type long.
(At times the value did not fit in the resulting type!)
In ANSI C,
the constant type is the first type encountered
in the list below that corresponds to the value:
unsuffixed decimal:-
int, long, unsigned long
unsuffixed octal or hexadecimal:-
int, unsigned int, long, unsigned long
U
suffixed:-
unsigned int, unsigned long
L
suffixed:-
long, unsigned long
UL
suffixed:-
unsigned long
The ANSI C compiler will warn you about any expression
whose behavior might change according to the typing rules
of the constants involved.
The old integral constant typing rules are used only in
the transition mode;
the ANSI C and conforming modes use the new rules.
Next topic:
Third example: integral constants
Previous topic:
Second example: result is the same
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003