integer *= float

Ed Hall edhall at randvax.ARPA
Fri Jan 6 13:38:13 AEST 1984


------------------------------
We have tried  integer *= float  with 5 different C compilers, and all
of them convert the float before the multiplication:
	1) PCC on the VAX,
	2) CC on the PDP-11 (i.e., the Ritchie compiler),
	3) the UniSoft C compiler on the CYB,
	4) AZTEC C on the APPLE,
	5) C-86 on the IBM PC (Computer Innovations).

I've seen at least two cases where code was broken due to this
counter-intuitive behavior.  A `fix' to PCC is not particularly
difficult (at least for the VAX); I have one, but won't post it
until this question is settled.

Thus, the VMS C compiler seems to be in the minority.  If the Ritchie
compiler is considered to be the `reference', then it would seem
that C does the counter-intuitive thing.  But reading the appropriate
part of K&R numerous times leaves me with the clear impression that the
conversion belongs after the operation and before the store.

		-Ed Hall
		decvax!randvax!edhall



More information about the Comp.lang.c mailing list