2
$\begingroup$

I've been making a program that can delay for any number of nanoseconds 0-65534 to any power 0-65534. That is to say, the shortest possible delay is 0^0 nanoseconds (1) and the longest possible delay is 65534^65534 nanoseconds (?). My problem is this: How can I discover the value of 65534^65534? I need this for several reasons, mainly documenting the behavior and telling the user the maximum possible delay. All calculators I've used have either given me an error such as OVERFLOW or Invalid input or simply said Infinity. I don't care about practicality; I'm sure this will work out to be millennia or something so ridiculous. I just want a straightforward answer, and, if possible, please stay away from using scientific notation

Also, I don't want to hear something like "Just write it out", because I'm not about to multiply any number by itself 65534 times.

$\endgroup$
0
15
$\begingroup$

Millennia is a short and cozy term here. We're talking about a something like a googol googol googol ... googol googols times the age of the universe. (In other words, your program can't count that long on any real hardware before the heat death of the universe cuts off the power; I don't think the universe would have room for the stupendous amounts of entropy that would be produced by even a single clock running for that many steps).

The best you can hope for is to express the number in exponential notation -- that is, take its logarithm: $$\log(65534^{65534}) = 65534\times \log(65534) = 315{,}642.327$$ So the answer is about $10^{315{,}633}$ seconds.

If you want to stay away from scientific notation, do you really want to write a number with three hundred thousand digits in your manual?

$\endgroup$
1
  • 1
    $\begingroup$ Ah yes - very true. Why didn't I think of that? $\endgroup$ – davidlowryduda Mar 12 '12 at 20:01
5
$\begingroup$

How about we give you an approximation?

Your number is certainly larger than $60000^{60000}$, which is in turn greater than $10000^{60000}$. Now $10000$ has $4$ factors of $10$, (i.e. it has 4 zeroes), so your number will have at least $60000 \cdot 4$ or about $250000$ zeroes after it. This is longer than the theoretical history of the universe. This is a number greater than the known number of atoms.

So one does not calculate this number. One marvels at how large it is.

$\endgroup$
4
$\begingroup$

I use Linux with Gnome-Shell and an extension that uses gnome calc to calculate whatever you want at a simple press of Windows button. It handled this without any trouble: but the answer has 315643 digits, $2.1\times10^{315642}$.

You need 100+ A4 sheets of paper to print this out.

If you need the exact value for a big-number expression and all your calculators suck at it, you can use any interpreting language with big numbers support, such as Haskell, and calculate it: consider this online haskell, and just type 65534^65534 there.

$\endgroup$
2
$\begingroup$

math.stackexchange didn't want to eat 315644 characters long post, so compute it yourself :-P

Python: (315644 because python prints the newline character)

time echo "print 65534**65534" | python | wc -c
315644
real    0m2.278s

Ruby:

time echo "print 65534**65534" | ruby | wc -c
315643
real    0m1.049s

Haskell:

time echo "main = putStr $ show $ 65534^65534" | runghc | wc -c
315643
real    0m0.269s
$\endgroup$
3
  • $\begingroup$ Oh, haha. I thought my version of python couldn't compute it very quickly. In actuality, the computation happened very quickly, IDLE was hanging without displaying the output. $\endgroup$ – user14972 Mar 12 '12 at 21:19
  • $\begingroup$ bc can also compute it quickly. By the way, the secret of these languages (as opposed to C, and Java) is that they use numeric types that allow you to express arbitrary large integers by default (or, in the case of Ruby, they switch to those types transparently): (1010).class => Fixnum, and (6553465534).class => Bignum. $\endgroup$ – Ken Bloom Mar 12 '12 at 23:48
  • $\begingroup$ "Haskell ... 0.269s" gotta love tail-end recursion $\endgroup$ – Ben Leggiero May 2 '14 at 5:02
1
$\begingroup$

approximately 10^(10^5.5). It will be a long delay considering that the age of the universe is around 4x 10^26 nanosecs.

In your notation you have many representations for the same number, that's you're wasting bits. You may not care about practicality but your users might. Think of potential user entry errors that will cause them to wait until eternity.

There is no easy way to write the resulting number without scientific notation since it will have 315,642 digits. Here are the first few digits 21242116357834319542444455315145680588833709612854343104165072458523808531209996640332737092605...

(source http://www.wolframalpha.com/input/?i=%282%5E16-2%29%5E%282%5E16-2%29)

$\endgroup$
1
$\begingroup$

Since post is limited to 30,000 characters long, I cannot write it down here, but there is calculator to give the exact number in pages and pages. https://defuse.ca/big-number-calculator.htm

$\endgroup$
0
$\begingroup$

It works out to be something close to $2.124\times 10^{315642}$ - there are various large number calculators on the internet that can deal with these huge numbers. I used this one simply because it was the first one to come up in a Google search. The downside to these things is that I would never know if they were just making it up, but I expect it's right!

$\endgroup$
0
$\begingroup$

The log base 10 should be easy to compute. A good computer algebra system or big integer library (e.g. GMP) should be able to compute it exactly. python can even compute it exactly -- just don't make the mistake of trying to display the full result unless you really mean to!

Of course, I doubt the exact value is of any use to you, and the log base 10 is good enough.

Here's wolframalpha's take on an approximate value:

http://www.wolframalpha.com/input/?i=65534%5E65534

$\endgroup$
0
$\begingroup$

Simple, use an dynamic array to store digits, rather than double in your program. This way you can have as much digits as memory you have. :)

But delay in C++ only works for milliseconds. So you have to divide by a 1000. :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.