Hi all. So I was wondering, what if I want numbers larger than BigInteger? If I understand, I can use many variables or many BigIntegers as one number. I am wondering how I would do such a thing. I have searched around a bit but I will keep looking.
Printable View
Hi all. So I was wondering, what if I want numbers larger than BigInteger? If I understand, I can use many variables or many BigIntegers as one number. I am wondering how I would do such a thing. I have searched around a bit but I will keep looking.
BigInteger has arbitrary bitlengths, and in theory can represent any integer. In practice, you'll run out of physical memory first or the OS/Java runtime will limit how much memory you have.
For a 1GB BigInteger, you can represent stupidly large numbers up to 2^4294967296. This is a 1,292,913,986 digit number.
This is significantly larger than the largest known prime as of Jan 15, 2013.
The only solution is to increase how much memory Java is allowed to use, or increase how much physical memory you have (or use virtual paged memory, though this is extremely slow).
is there a way to tell how much memory the variable is taking?