Is there a BigInteger class in PHP?

freddiefujiwara picture freddiefujiwara · Dec 13, 2010 · Viewed 15.9k times · Source

Is there a BigInteger class in PHP? If so, how do I access it or use it?

Answer

Thariama picture Thariama · Dec 13, 2010

Hopefully helpfull links :

EDIT: Math_BigInteger

Example from http://phpseclib.sourceforge.net/documentation/math.html :

Implements an arbitrary precision integer arithmetic library. Uses gmp or bcmath, if available, and an internal implementation, otherwise.

<?php
    include('Math/BigInteger.php');

    $a = new Math_BigInteger(2);
    $b = new Math_BigInteger(3);

    $c = $a->add($b);

    echo $c->toString(); // outputs 5
?>