I believe the reason it works is that all of the operands are evaluated
as signed 32-bit integers, causing the overflow. When you assign the value
to testmath1, it is a long, which causes the second expression to have all
of its operands converted to 64 bit integers. In order to get this to work
in one line, this should work:
long testmath = ((long) (898 * 360 + 30)) * 24 * 60 * 60 * 1000 / 25;
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Unknown" <Un*****@Unknown.COM> wrote in message
news:Xn*******************************@140.99.99.1 30...
Why does this overflow?
long testmath = (898 * 360 + 30) * 24 * 60 * 60 * 1000 / 25;
but if I do it this way it works..
long testmath1 = (898 * 360 + 30)
long testmath2 = testmath1 * 24 * 60 * 60 * 1000 / 25;
How can I get it so that it works properly in the first definition..?
Thanks.