Programming Tips - How can I do math with really big numbers in PHP?

Date: 2017oct3 Language: php Keywords: GNU Multiple Precision Arithmetic Library, Maple, Wolfram Alpha, Mathematica Q. How can I do math with really big numbers in PHP? A. Use the built-in GMP (GNU Multiple Precision) library. Examples:
$x = gmp_init('12345678901234567890'); $y = gmp_init('12345678901234567890'); $prod = gmp_mul($x, $y); $strprod = gmp_strval($prod); print "x * y = $strprod\n"; $fact = gmp_fact(100); $strfact = gmp_strval($fact); print "factorial=$strfact\n";
You don't need to import anything to use this.