Strange multiplication (to me anyway!)

Does anyone know why this line of code would give this value!?long l = 5965*5965*67; (actual answer should be 2 383 942 075)In my debugger it says:long l = -1911025221Any help appreciated!
[223 byte] By [MutDa] at [2007-11-26 20:59:12]
# 1
The righthand side is of type int, and the int value overflowed. To fix it:long l = 5965L*5965*67;
DrLaszloJamfa at 2007-7-10 2:29:28 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks, that worked for when i'm using explicit numbers, how do I get it to do the same thing for this;long l = (a*b*c) + 1;Many thanks again.
MutDa at 2007-7-10 2:29:28 > top of Java-index,Java Essentials,New To Java...
# 3

> Thanks, that worked for when i'm using explicit

> numbers, how do I get it to do the same thing for

> this;

Cast one of them to a long.

long l = (long)a * b * c + 1;

Now give the Doc a Duke! He needs his star.

CaptainMorgan08a at 2007-7-10 2:29:28 > top of Java-index,Java Essentials,New To Java...
# 4
Does casting bind tighter than multiplication, or do we need to do ((long)a) * b * c?
jverda at 2007-7-10 2:29:29 > top of Java-index,Java Essentials,New To Java...
# 5
Cheers guys, all sorted! (Captain did u mean you or the guy who first replied!? I gave them to him because thats who I thought you meant!)Message was edited by: MutD
MutDa at 2007-7-10 2:29:29 > top of Java-index,Java Essentials,New To Java...
# 6
> Does casting bind tighter than multiplicationYes.> or do we need to do ((long)a) * b * c?My code works. (I just tested it to make sure)
CaptainMorgan08a at 2007-7-10 2:29:29 > top of Java-index,Java Essentials,New To Java...
# 7
> Cheers guys, all sorted! (Captain did u mean you or> the guy who first replied!? I gave them to him> because thats who I thought you meant!)That's who I meant. ;-)
CaptainMorgan08a at 2007-7-10 2:29:29 > top of Java-index,Java Essentials,New To Java...
# 8
> > Does casting bind tighter than multiplication> > Yes.> > > or do we need to do ((long)a) * b * c?> > My code works. (I just tested it to make sure)Okay, cool. I was too lazy to check.
jverda at 2007-7-10 2:29:29 > top of Java-index,Java Essentials,New To Java...