>"Shankar Unni" <[EMAIL PROTECTED]> wrote in message
>news:2288@palm-dev-forum...
> >
> > Well, what is it supposed to do? Technically, according to the C standard,
> > anyway, this operation has undefined effects, because you are converting a
> > negative number ((signed long) (y - z) * 10) into an unsigned number in
> > order to add to "x".
>
>So:
>
> unsigned int x, y;
>
> x = 6;
> y = x + -1;
>
>will give undefined results? I find this hard to believe.
On some machines, it will.
Consider the case where sizeof (int) == sizeof (long).
(A quite common case on modern processors.)
Harbison and Steel say (section 6.3.2, page 162) that
when one operand is "unsigned long", the other operand
is converted to "unsigned long".
Since -1 cannot be represented as an "unsigned long",
the results are undefined.
[ A common result is that -1 is converted to 4,294,967,295 (0xFFFFFFFF),
and added to 6, and the result is then given as 4,294,967,301 modulo 4,294,967,296,
which is the correct answer, 5. But this behavior is certainly not guaranteed. ]
-- Marshall
"The era of big government is over."
Bill Clinton, State of the Union Address, January 23, 1996
Marshall Clow Adobe Systems <mailto:[EMAIL PROTECTED]>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html