Calculating Nth root with bcmath in PHP
问题 We are looking for the Nth root in PHP. We need to do this with a very large number, and the windows calculator returns 2. With the following code we are getting 1. Does anybody have an idea how this works? echo bcpow(18446744073709551616, 1/64); 回答1: Well it seems that PHP and the BC lib has some limits, and after searching on the internet i found this interesting article/code: So you should use this function: <?php function NRoot($num, $n) { if ($n<1) return 0; // we want positive exponents