The very fact that there is so much disagreement on this simple point
explains why so many C programs are full of so many bugs! [Please pardon my
sacrilege if you are in the "C is my religion" group ;) ]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Saturday, February 26, 2000 1:08 PM
Subject: Re: Simple multiplication madness (long reply)
> In a message dated 2/25/00 10:08:31 PM Eastern Standard Time,
> [EMAIL PROTECTED] writes:
>
> > So, when the compiler sees
> > (Long) 10 * 3600
> > it multiplies an int 10 by an int 3600, then casts the result to a
> > long. Unfortunately, the 10 * 3600 = 36000, which is too large for an
> > int. The result is a (silent) math overflow. All you're doing is
> > casting the wrong value to a long!
> >
> > If you want to override the compiler's default interpretation of
> > literals, you have to tell it. Append an 'L' to a literal to make the
> > compiler interpret it as long:
> > long result;
> > result = 10L * 3600L;
>
> I politely disagree.
>
> (Long) 10 * 3600 will typecast 10 into a 32-bit value before doing the
> computation. Hence the result will be the same 32-bit value that you get
by
> using 10L.
>
> -Pete
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html