Since I started using eclipse for project euler, I noticed that big numbers sometime become a seemingly random negative numbers. I suppose this has something to do with pass
You are probably overflowing the size of your data type, since the most significant bit is the sign bit. I don't think that Java has unsigned
data types, so you may try using a larger data type such as long
if you want to hold bigger numbers than int
. If you are still overflowing a long
though, you're pretty much stuck with BigInteger
.