Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!accelerator.eng.ohio-state.edu!raksha.eng.ohio-state.edu!rob From: rob@raksha.eng.ohio-state.edu (Rob Carriere) Newsgroups: comp.std.c Subject: Re: nonportable code or incorrect compilers? Message-ID: <374@accelerator.eng.ohio-state.edu> Date: 8 Jul 88 15:04:05 GMT References: <133@daitc.ARPA> <430@uwovax.uwo.ca> Sender: news@accelerator.eng.ohio-state.edu Reply-To: rob@raksha.eng.ohio-state.edu (Rob Carriere) Organization: Ohio State Univ, College of Engineering Lines: 19 In article <133@daitc.ARPA>, jkrueger@daitc.ARPA (Jonathan Krueger) writes: > [...] predict the output of the following code: > #define DEFCONST 1.05 > main(){ > int count = 800; > printf("count is %d, ", count); > count *= DEFCONST; > printf("now %d\n", count); > } > My prediction, based on K&R, was the output: count is 800, now 839 K&R says that ``a*=b'' is eqv to ``a=a*b'' *except* that ``a'' is evaluated only once. Sounds like the type cast is not going to be done => 800 is right. I don't know about ANSI, I *hope* they changed this; it's horribly counterintuitive. Yes, I'm biased; this is what my favorite compiler (Mark Williams C) says. Rob Carriere