subtraction between unsigned ints

Walter Murray walter at hpclwjm.HP.COM
Fri Sep 8 09:26:48 AEST 1989


Doug Gwyn writes:

>In article <KURO.89Sep5111940 at shochu.Sun.Com> kuro at shochu.Sun.Com (Teruhiko Kurosaka - Sun Intercon) writes:
>>Does pANSI defines the datatype of the result of subtraction
>>between unsigned integers?  Would it be also unsigned?

>Yes, the type of the result of any arithmetic combination of operands
>having a single arithmetic type is the same type as that of the operands.

But note that the usual arithmetic conversions are still performed.
So if s1 and s2 have type short int, for example, the expression
(s1+s2) has type int, not short int.

Walter Murray
-------------



More information about the Comp.std.c mailing list