🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #583

Re: subtraction between unsigned ints

#583
From: Norman Diamond
Date: Wed, 13 Sep 1989 10:16
35 lines
1935 bytes
Someone asked:

>>>Does pANSI defines the datatype of the result of subtraction
>>>between unsigned integers?  Would it be also unsigned?  Then
>>>what would be the result of subtraction of a number from a
>>>smaller number?

I answered:

>>It always has been unsigned, even in K&R days.  pANS says that the
>>result must wrap around modulo some power of 2; this was not required
>>by K&R but surely always occured.

In article <12570024@hpclwjm.HP.COM> walter@hpclwjm.HP.COM (Walter Murray) writes:

>I think it was required by K&R.  See Appendix A, section 6.5, in the
>first edition (page 184).

That section specifies conversion from [signed] int to unsigned int.
It does not specify the result of subtraction.

Hmm, this raises a new question.  Someone who had the good fortune to
receive service from Global Engineering Documents, please kindly answer:

Does the standard specify the same conversion as K&R-1 did?  Or is this
another quiet change?  On a 1's complement machine, K&R-1 required more
computation than just a move instruction.  Do the pants impose the same
requirement?

--
-- 
Norman Diamond, Sony Corporation (diamond@ws.sony.junet)
  The above opinions are inherited by your machine's init process (pid 1),
  after being disowned and orphaned.  However, if you see this at Waterloo or
  Anterior, then their administrators must have approved of these opinions.
Technical Details
Message-ID: <10833@riks.csl.sony.co.jp>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!uunet!kddlab!ccut!titcca!sragwa!wsgw!socslgw!diamond
References: <KURO.89Sep5111940@shochu.Sun.Com> <12570024@hpclwjm.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!uunet!kddlab!ccut!titcca!sragwa!wsgw!socslgw!diamond
From: diamond@csl.sony.co.jp (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: subtraction between unsigned ints
Message-ID: <10833@riks.csl.sony.co.jp>
Date: 13 Sep 89 10:16:16 GMT
References: <KURO.89Sep5111940@shochu.Sun.Com> <12570024@hpclwjm.HP.COM>
Reply-To: diamond@ws.sony.junet (Norman Diamond)
Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan
Lines: 35