Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.std.c
Subject: Re: nonportable code or incorrect compilers?
Message-ID: <8228@brl-smoke.ARPA>
Date: 8 Jul 88 17:59:09 GMT
References: <133@daitc.ARPA> <430@uwovax.uwo.ca> <374@accelerator.eng.ohio-state.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 15

In article <374@accelerator.eng.ohio-state.edu> rob@raksha.eng.ohio-state.edu (Rob Carriere) writes:
>K&R says that ``a*=b'' is eqv to ``a=a*b'' *except* that ``a'' is
>evaluated only once.

Yes.

>Sounds like the type cast is not going to be done => 800 is right.

I didn't see any cast operator.  If you mean type conversion,
one IS supposed to be done in order to evaluate a*b where a is
an int and b is a double.  Then the assignment to a should
truncate the double expression value back to an int.

The correct answer is 839 or 840, depending on how precise your
floating-point architecture is.  800 is definitely incorrect.