没有PHP扩展的大数字(权力......)

<?php
$res = pow(5, pow(5, pow(5, pow(5, 5))));
echo $res;

Outputs :

INF

I know it cannot be stored in a 64 bit float, but is there a way to calculate this kind of big number ? All my attempts failed (always this "INF").

EDIT : Yes, I know that this number is huge, and that's really what I'm trying to calculate. Also, I'm trying to do it without extensions (unless I fully understand what the extension does and I'm able to code it myself).

Edit: As noted in the comments, the GMP extension may work, and may be more suited to integer math.

Another commenter suggested providing more information than links. The extensions noted in this and other answers are better-suited than the standard built-in php functions for either larger ints or more precise floating-point numbers.

But... you may not be able to just chain the results together with gmp_pow the same way you did in the question. For one thing, you need php 5.6 to use a gmp number as the parameter for gmp_pow.

For another thing, the number is so large, you might need to use gmp_powm, as explained in this answer

Original Answer You could try BCMath extension although it may not be installed by default. (although BCMath may be better for working with floating points rather than Ints)

you can try to use http://pear.php.net/package/Math_BigInteger/docs It can be installed via pear

These two will help - BC Math extension - GMP library