Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site cubsvax.UUCP Path: utzoo!linus!philabs!cubsvax!peters From: peters@cubsvax.UUCP (Peter S. Shenkin) Newsgroups: net.lang.c Subject: Re: i = i * f *vs* i *= f (Not a bug) (Yes, a bug!) Message-ID: <207@cubsvax.UUCP> Date: Tue, 17-Apr-84 11:30:32 EST Article-I.D.: cubsvax.207 Posted: Tue Apr 17 11:30:32 1984 Date-Received: Thu, 19-Apr-84 01:03:26 EST References: <2310@ecsvax.UUCP> Organization: Columbia Univ Biology, New York City Lines: 23 Re: Bennett Todd's assertion that the problem is not a bug: cf K&R p 41: "In general, if... a "binary operator" has operands of different types, the "lower" type is *promoted* to the "higher" before the operation proceeds.... This, coupled with their assertion elsewhere that x = x op y "may be taken as equivalent" (or words to that effect) to x op= y, would seem to indicate that i *= f and i = i * f should evaluate the expression with i and f as floats, then cast the result to int. In any case, they should evaluate the expression the same way! If you disagree, quote me chapter and verse. Net effect: it's a bug! Moral: beware implicit type conversions, since they may not do what K&R says they do. By the way, I'd be curious to see the results of the program on other compilers. {philabs,cmcl2!rocky2}!cubsvax!peters Peter S. Shenkin Dept of Biol. Sci.; Columbia Univ.; New York, N. Y. 10027; 212-280-5517 "In accordance with the recent proclivity for clever mottos, this is mine."