Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!akgua!mcnc!ecsvax!bet From: bet@ecsvax.UUCP Newsgroups: net.lang.c Subject: Re: i = i * f *vs* i *= f (Not a bug) Message-ID: <2310@ecsvax.UUCP> Date: Sun, 15-Apr-84 16:03:13 EST Article-I.D.: ecsvax.2310 Posted: Sun Apr 15 16:03:13 1984 Date-Received: Sun, 15-Apr-84 23:47:20 EST Lines: 14 What we have here is a type conversion problem. When i = i * f is evaulated, the "i" on the right side of the assignment is promoted to float, the expression is evaluated, and the result is converted back to integer for the assignment. 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. C is perhaps as benign as any environment I know. Look at PL/I for crissakes. If ANY numeric value gets converted to fixed decimal, you stand a good chance of getting badly burnt. Literal numeric constants (as I recall) default to fixed decimal. OUCH!!! Bennett Todd ...{decvax,ihnp4,akgua}!mcnc!ecvax!bet