Promotion of integral types

Chris Thomson cmt at myrias.UUCP
Tue Sep 23 18:35:37 AEST 1986


In article <3422 at umcp-cs.UUCP> Chris Torek writes:

> 	Storage Type		Expression Equivalent
> 	------------		---------------------
> 	char			int
> 	unsigned char		unsigned int
> 	short			int
> 	unsigned short		unsigned int
> 	int			int
> 	unsigned int		unsigned int
> 	long			long
> 	unsigned long		unsigned long
> 	float			double
> 	double			double
> 	pointer			pointer

It is interesting to note that K&R does not say that unsigned char or
unsigned short get promoted to unsigned int; it says that they get promoted
to integer (on page 183), which is a bit vague.  Harbison & Steele says
very clearly what is said above.  The ANSI Draft (1986.07.09 version) says
very clearly that unsigned char and unsigned short are promoted to int,
since the values can all be represented in an int (assuming sizeof(int)
is greater than sizeof(short), which is usually true).

What to do?  Frankly, I prefer the ANSI approach, but it does represent a
silent change from what H&S (and Chris Torek) perceive to be standard
practice.  For some reason, it is not flagged as such in the rationale
document; it isn't even discussed there.
-- 
Chris Thomson, Myrias Research Corporation	   alberta!myrias!cmt
200 10328 81 Ave, Edmonton Alberta, Canada	   403-432-1616



More information about the Comp.lang.c mailing list