nonportable code or incorrect compilers?

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Jul 9 03:59:09 AEST 1988


In article <374 at accelerator.eng.ohio-state.edu> rob at 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.



More information about the Comp.std.c mailing list