Reputation: 1883
Is that theoretically possible? Even BigIntegers
should fail, AFAIK, since they are internally based on an Array, and these have a limited size. Is it possible to directly calculate with the exponential form of googolplexes in Java? for example: ((10^10^100)/2)-5
How do I prepare an application, which has googol-sized numbers as genuine results?
(For those who don't know: a googol == 10^100
, a googolplex == 10^10^100
)
Upvotes: 2
Views: 1566
Reputation: 1
Make a logical calculation like a child divide 12÷5. Consider a longer digit 123456÷54321 and start with len function, this will enable you to identify that there are two folfs of 54321 in 123456. So seperate each digit of 54321 and multiply each with 2 (keep 10th adding to the next level). Now index the result and subtract from the index of 123456 individual digits. Make a program for 12÷5 and you will be able to divide large numbers upto google numbers and above.
Upvotes: 0
Reputation: 1370
Why not use BigInteger
?
this works:
String googolString = "1";
for (int i = 0; i < 100; ++i) {
googolString += "0";
}
BigInteger googol = new BigInteger(googolString);
String googolPlexString = "1";
BigInteger googolPlex;
for (int i = 0; i < googolString.length() - 1; ++i) {
for (int j = 0; j < 100; ++j) {
googolPlexString += "0";
}
}
googolPlex = new BigInteger(googolPlexString);
googolPlex = googolPlex.divide(new BigInteger("2"));
googolPlex = googolPlex.subtract(new BigInteger("5"));
But yes storing a number, not a symbol of the number, but the binary representation of a number would be impossible for numbers large enough.
Upvotes: -1
Reputation: 2210
Think of it as how you would calculate scientific notation calculations: For example 2.574e100 * 4.762e15724 can be calculated as (2.574 * 4.762)e(100*15724), rather than calculating 2.574e100 and 4.762e15724 separately, then multiplying them together.
So theoretically possible, and not too difficult to implement. Googol can be represented by two integers, 10 and 100, just like you did in your question when you said "a googol == 10^100".
A more simple explanation of what I said above is this: You wouldn't write googol as 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, you would write it as 10^100. Make the computer do the same.
Upvotes: 1
Reputation: 4014
I think you should try symbolic math library. Symbolic math library perform operations on equation structure and do not try to represent numbers internally.
Some links to start:
https://code.google.com/p/symja/
http://www4.ncsu.edu/~kaltofen/bibliography/99/BCK99.pdf
Good luck.
Upvotes: 5