* @copyright 2019 Jim Wigginton * @license http://www.opensource.org/licenses/mit-license.html MIT License * @link http://phpseclib.sourceforge.net */ use bcmath_compat\BCMath; if (!function_exists('bcadd')) { /** * Add two arbitrary precision numbers * * @var string $left_operand * @var string $right_operand * @var int $scale optional */ function bcadd($left_operand, $right_operand, $scale = 0) { return BCMath::add($left_operand, $right_operand, $scale); } /** * Compare two arbitrary precision numbers * * @var string $left_operand * @var string $right_operand * @var int $scale optional */ function bccomp($left_operand, $right_operand, $scale = 0) { return BCMath::comp($left_operand, $right_operand, $scale); } /** * Divide two arbitrary precision numbers * * @var string $dividend * @var string $divisor * @var int $scale optional */ function bcdiv($dividend, $divisor, $scale = 0) { return BCMath::div($dividend, $divisor, $scale); } /** * Get modulus of an arbitrary precision number * * @var string $dividend * @var string $divisor * @var int $scale optional */ function bcmod($dividend, $divisor, $scale = 0) { return BCMath::mod($dividend, $divisor, $scale); } /** * Multiply two arbitrary precision numbers * * @var string $left_operand * @var string $right_operand * @var int $scale optional */ function bcmul($dividend, $divisor, $scale = 0) { return BCMath::mul($dividend, $divisor, $scale); } /** * Raise an arbitrary precision number to another * * @var string $base * @var string $exponent * @var int $scale optional */ function bcpow($base, $exponent, $scale = 0) { return BCMath::pow($base, $exponent, $scale); } /** * Raise an arbitrary precision number to another, reduced by a specified modulus * * @var string $base * @var string $exponent * @var string $modulus * @var int $scale optional */ function bcpowmod($base, $exponent, $modulus, $scale = 0) { return BCMath::powmod($base, $exponent, $modulus, $scale); } /** * Set or get default scale parameter for all bc math functions * * @var int $scale */ function bcscale($scale = null) { return BCMath::scale($scale); } /** * Get the square root of an arbitrary precision number * * @var string $operand * @var int $scale optional */ function bcsqrt($operand, $scale = 0) { return BCMath::sqrt($operand, $scale); } /** * Subtract one arbitrary precision number from another * * @var string $left_operand * @var string $right_operand * @var int $scale optional */ function bcsub($left_operand, $right_operand, $scale = 0) { return BCMath::sub($left_operand, $right_operand, $scale); } } // the following were introduced in PHP 7.0.0 if (!class_exists('Error')) { class Error extends Exception { } class ArithmeticError extends Error { } class DivisionByZeroError extends ArithmeticError { } class TypeError extends Error { } } // the following was introduced in PHP 7.1.0 if (!class_exists('ArgumentCountError')) { class ArgumentCountError extends TypeError { } } // the following was introduced in PHP 8.0.0 if (!class_exists('ValueError')) { class ValueError extends Error { } }