Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site bbncc5.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!bbncc5!keesan From: keesan@bbncc5.UUCP (Morris M. Keesan) Newsgroups: net.lang.c Subject: Re: c programming style - READ THIS Message-ID: <247@bbncc5.UUCP> Date: Mon, 29-Jul-85 10:44:52 EDT Article-I.D.: bbncc5.247 Posted: Mon Jul 29 10:44:52 1985 Date-Received: Wed, 31-Jul-85 03:18:51 EDT References: <11570@brl-tgr.ARPA> <935@teddy.UUCP> <1286@uwmacc.UUCP> <2439@sun.uucp> <734@lsuc.UUCP> Reply-To: keesan@bbncc5.UUCP (Morris M. Keesan) Organization: Bolt Beranek and Newman, Cambridge, MA Lines: 19 Keywords: RTM Summary: a++ is equivalent to a+=1 In article <734@lsuc.UUCP> dave@lsuc.UUCP (David Sherman) writes: >In article <2439@sun.uucp> guy@sun.uucp (Guy Harris) writes: >|| 2) "++a" and "a += 1" are completely equivalent expressions. > >Well, almost. On at least some systems, "a++" won't work if a is >float, while "a += 1" will add 1.0 to a. Those systems are buggy. The C compiler for the BBN C/70 used to not support ++ and -- on floats, because the compiler maintainer said they were "nonsensical". When I inherited the compiler, I added code to the first pass which would convert "++a" to "a+=1" for floating a. From the C Reference Manual, section 7.2 (p. 187, K&R): "The expression ++x is equivalent to x+=1. See the discussions of addition and assignment operators for information on conversions." The "usual arithmetic conversions" in this case cause "a += 1" to be equivalent to "a += 1.0". -- Morris M. Keesan keesan@bbn-unix.ARPA {decvax,ihnp4,etc.}!bbncca!keesan