Would *you* get caught by this one?
Tony Williams
tonyw at microsoft.UUCP
Sat Jan 14 06:09:58 AEST 1989
In article <139 at mole-end.UUCP> mat at mole-end.UUCP (Mark A Terribile) writes:
>Here's a simple C question on a point that caught me recently. Would *you*
>get caught?
>
> When is a *= b not the same as a = a * b ?
I think the proper answer is when your C compiler has a bug :-)
More seriously, here is one that not many C compilers get right:
int a = 2;
a *= 0.5;
Most compilers give you a == 0 following the *= statement, and a == 1
following a statment a = a * 0.5;
(Thanks to Jeff Smith at Warwick, UK for pointing this one out to me)
Tony Williams
More information about the Comp.lang.c
mailing list