Kinz
Kinz

Reputation: 310

Increase Java's Computational Abilities

So I'm not sure exactly if this is a problem of Eclipse, Java, or my computer. What I'm trying to do is basically 2^57885161-1. But, sadly, all that Eclipse outputs is "Infinity". My deduction is either that Java sets a limit to the maximum of a computed equation, Eclipse does, or that my Computer cannot handle the amount of computational ability it would require.

If it is Java or Eclipse, is there a way that I can remedy the situation?

Thank you.

Upvotes: 1

Views: 90

Answers (1)

scott_fakename
scott_fakename

Reputation: 10789

Use the java.math.BigDecimal (or java.math.BigInteger) class for extremely large numbers.

What's probably happening is that you're using an int or a double, and that number is MUCH too large for those datatypes in Java. Using BigDecimal, which can be arbitrarily long, will solve your problem given time.

edit - previously I had written "java.util.BigDecimal", which is the wrong package.

Upvotes: 4

Related Questions