Domanda

How to handle 1000 digit number? Anyone can explain it?

My code;

 Long sum = 1L;
 ...

 if (String.valueOf(sum).length() == 1000) {
    ...
 }

But not working, anyone can explain it?

È stato utile?

Soluzione

Use the class BigInteger, it can handle arbitrary long numbers (that is, as big as computer memory allows).

Link: http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html

Altri suggerimenti

Use a BigInteger instead. See the documentation here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top