Sujet : Re: Command Languages Versus Programming Languages
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.unix.programmerDate : 22. Nov 2024, 23:16:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <e47664d3-7f9b-4e67-aa73-b72c6cc0687a@alumni.caltech.edu>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 11/22/24 16:14, Dan Cross wrote:
...
irrelevant. That's not how C works: C will promote those
`unsigned char` values to `signed int` before it does the
subtraction. It does this because `unsigned char` has _rank_
lower than _int_ ...
True.
... and the entire range of values is expressible
in a signed int.
Not necessarily. An implementation is allowed to have UCHAR_MAX >
INT_MAX, in which case unsigned char promotes to unsigned int rather
than int. I'm aware of systems where UCHAR_MAX > LONG_MAX was true:
char, short, int, and long were all 32 bits.
... These are called, "the usual arithmetic
conversions."
Actually, what you're talking about are the integer promotions. The
first step of the usual arithmetic conversions is to apply the integer
promotions to each operand, but then a few other things happen as well.