i = i * f *vs* i *= f (Not a bug) (Oh yes it is)

Guido van Rossum guido at mcvax.UUCP
Tue Apr 17 13:59:26 AEST 1984


bet at ecsvax.UUCP (Bennett Todd) says:

>What we have here is a type conversion problem.
>[...]  When i *= f is evaluated, the right side of the assignment
>operator is evaluated, just as before: it is the float. It is then converted
>to integer for the assignment operation: 0.2 goes to 0 in any reasonable
>conversion. BEWARE incautious mixed types: they ALWAYS ALWAYS ALWAYS bite
>back.

NO, NO, NO!  This subject has been beaten to death (in this newsgroup or
in net.unix-wizards?) a few months ago.  It is a definite compiler bug,
which unfortunately lingers around in almost all compilers available.
This makes the last quoted phrase understandable, but it's the compilers,
not the language that bites.  Compilers can be fixed.

(BTW, look in K&R: somewhere it says a *= b is treated as a = a*b
except for the side effects of computing a's address.)

--
	Guido van Rossum, "Stamp Out Basic" Committee, CWI, Amsterdam
	guido @ mcvax



More information about the Comp.lang.c mailing list