subtraction between unsigned ints

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Sep 9 11:26:51 AEST 1989


In article <12570023 at hpclwjm.HP.COM> walter at hpclwjm.HP.COM (Walter Murray) writes:
-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.

Yes, I was trying to put it succinctly.  What I described was strictly
accurate only for arithmetic types that don't undergo the usual arithmetic
conversions when combined with other operands of their own type.  Unsigned
int is one of those.



More information about the Comp.std.c mailing list