c programming style - READ THIS

Morris M. Keesan keesan at bbncc5.UUCP
Tue Jul 30 00:44:52 AEST 1985


In article <734 at lsuc.UUCP> dave at lsuc.UUCP (David Sherman) writes:
>In article <2439 at sun.uucp> guy at 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 at bbn-unix.ARPA
{decvax,ihnp4,etc.}!bbncca!keesan



More information about the Comp.lang.c mailing list