| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 | <?php/* * This file is part of Hashids. * * (c) Ivan Akimov <ivan@barreleye.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */namespace Hashids\Math;/** * This is the Bc math class. * * @author Vincent Klaiber <hello@doubledip.se> * @author Jakub Kramarz <lenwe@lenwe.net> * @author Johnson Page <jwpage@gmail.com> */class Bc implements MathInterface{    /**     * Add two arbitrary-length integers.     *     * @param string $a     * @param string $b     *     * @return string     */    public function add($a, $b)    {        return bcadd($a, $b, 0);    }    /**     * Multiply two arbitrary-length integers.     *     * @param string $a     * @param string $b     *     * @return string     */    public function multiply($a, $b)    {        return bcmul($a, $b, 0);    }    /**     * Divide two arbitrary-length integers.     *     * @param string $a     * @param string $b     *     * @return string     */    public function divide($a, $b)    {        return bcdiv($a, $b, 0);    }    /**     * Compute arbitrary-length integer modulo.     *     * @param string $n     * @param string $d     *     * @return string     */    public function mod($n, $d)    {        return bcmod($n, $d);    }    /**     * Compares two arbitrary-length integers.     *     * @param string $a     * @param string $b     *     * @return bool     */    public function greaterThan($a, $b)    {        return bccomp($a, $b, 0) > 0;    }    /**     * Converts arbitrary-length integer to PHP integer.     *     * @param string $a     *     * @return int     */    public function intval($a)    {        return intval($a);    }    /**     * Converts arbitrary-length integer to PHP string.     *     * @param string $a     *     * @return string     */    public function strval($a)    {        return $a;    }    /**     * Converts PHP integer to arbitrary-length integer.     *     * @param int $a     *     * @return string     */    public function get($a)    {        return $a;    }}
 |