Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Division operation of very large numbers in PHP
Division operation of very large numbers in PHP

Even in PHP under the 64bit system, the integer type can only achieve the accuracy of 2 to the 63rd power.

What you gave is 2 to the power of 2900, which is far beyond the accuracy. Even using floating point, the order of magnitude cannot be recorded.

You need to use the GMP module separately

Enable it in php.ini

extension=php_gmp.dll; or rewrite the code so

$a=gmp_init(2);

$b=gmp_pow($a,2900);

echo?'b:'. gmp_strval($b).'
';

$d=gmp_init(3233);

$e=gmp_div_r($b,$d);

echo?'e:'.gmp_strval($e);b:

e:2060

ps: Off topic but back to the topic, when something inexplicable occurs, you need to use the big Numerical operations are usually caused by a weak grasp of the coding foundation, and such hard algorithms can mostly be avoided.