int divided by unsigned.
Jim Giles
jlg at lanl.gov
Tue Jun 27 13:13:08 AEST 1989
>From article <1549 at frog.UUCP>, by john at frog.UUCP (John Woods):
> main() {
> int a = -5;
> unsigned b = 1000;
> printf("%d\n", a /= (int)b);
> }
> A correct program giving desirable results. Fancy that.
And all it requires is some non-intuitive (and undesireable) clutter
in the expression. It would _obviously_ be better if the semantics of
the given expression were the _default_ and the present default were
the one which required the extra syntax. That is, all the following
would be _equal_:
a /= b, (int)a /= b, a /= (int)b, (int)a /= (int)b
and, to get the current interpretation, you should have to do:
(unsigned)a /= b
But, that would require C to do something in a reasonable way - so I
guess we can forget that.
More information about the Comp.lang.c
mailing list