[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/phpseclib/bcmath_compat/lib/ -> bcmath.php (source)

   1  <?php
   2  
   3  /**
   4   * bcmath polyfill
   5   *
   6   * PHP versions 5 and 7
   7   *
   8   * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
   9   * of this software and associated documentation files (the "Software"), to deal
  10   * in the Software without restriction, including without limitation the rights
  11   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12   * copies of the Software, and to permit persons to whom the Software is
  13   * furnished to do so, subject to the following conditions:
  14   *
  15   * The above copyright notice and this permission notice shall be included in
  16   * all copies or substantial portions of the Software.
  17   *
  18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24   * THE SOFTWARE.
  25   *
  26   * @author    Jim Wigginton <[email protected]>
  27   * @copyright 2019 Jim Wigginton
  28   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  29   * @link      http://phpseclib.sourceforge.net
  30   */
  31  
  32  use bcmath_compat\BCMath;
  33  
  34  if (!function_exists('bcadd')) {
  35      /**
  36       * Add two arbitrary precision numbers
  37       *
  38       * @var string $left_operand
  39       * @var string $right_operand
  40       * @var int $scale optional
  41       */
  42      function bcadd($left_operand, $right_operand, $scale = 0)
  43      {
  44          return BCMath::add($left_operand, $right_operand, $scale);
  45      }
  46  
  47      /**
  48       * Compare two arbitrary precision numbers
  49       *
  50       * @var string $left_operand
  51       * @var string $right_operand
  52       * @var int $scale optional
  53       */
  54      function bccomp($left_operand, $right_operand, $scale = 0)
  55      {
  56          return BCMath::comp($left_operand, $right_operand, $scale);
  57      }
  58  
  59      /**
  60       * Divide two arbitrary precision numbers
  61       *
  62       * @var string $dividend
  63       * @var string $divisor
  64       * @var int $scale optional
  65       */
  66      function bcdiv($dividend, $divisor, $scale = 0)
  67      {
  68          return BCMath::div($dividend, $divisor, $scale);
  69      }
  70  
  71      /**
  72       * Get modulus of an arbitrary precision number
  73       *
  74       * @var string $dividend
  75       * @var string $divisor
  76       * @var int $scale optional
  77       */
  78      function bcmod($dividend, $divisor, $scale = 0)
  79      {
  80          return BCMath::mod($dividend, $divisor, $scale);
  81      }
  82  
  83      /**
  84       * Multiply two arbitrary precision numbers
  85       *
  86       * @var string $left_operand
  87       * @var string $right_operand
  88       * @var int $scale optional
  89       */
  90      function bcmul($dividend, $divisor, $scale = 0)
  91      {
  92          return BCMath::mul($dividend, $divisor, $scale);
  93      }
  94  
  95      /**
  96       * Raise an arbitrary precision number to another
  97       *
  98       * @var string $base
  99       * @var string $exponent
 100       * @var int $scale optional
 101       */
 102      function bcpow($base, $exponent, $scale = 0)
 103      {
 104          return BCMath::pow($base, $exponent, $scale);
 105      }
 106  
 107      /**
 108       * Raise an arbitrary precision number to another, reduced by a specified modulus
 109       *
 110       * @var string $base
 111       * @var string $exponent
 112       * @var string $modulus
 113       * @var int $scale optional
 114       */
 115      function bcpowmod($base, $exponent, $modulus, $scale = 0)
 116      {
 117          return BCMath::powmod($base, $exponent, $modulus, $scale);
 118      }
 119  
 120      /**
 121       * Set or get default scale parameter for all bc math functions
 122       *
 123       * @var int $scale
 124       */
 125      function bcscale($scale = null)
 126      {
 127          return BCMath::scale($scale);
 128      }
 129  
 130      /**
 131       * Get the square root of an arbitrary precision number
 132       *
 133       * @var string $operand
 134       * @var int $scale optional
 135       */
 136      function bcsqrt($operand, $scale = 0)
 137      {
 138          return BCMath::sqrt($operand, $scale);
 139      }
 140  
 141      /**
 142       * Subtract one arbitrary precision number from another
 143       *
 144       * @var string $left_operand
 145       * @var string $right_operand
 146       * @var int $scale optional
 147       */
 148      function bcsub($left_operand, $right_operand, $scale = 0)
 149      {
 150          return BCMath::sub($left_operand, $right_operand, $scale);
 151      }
 152  }
 153  
 154  // the following were introduced in PHP 7.0.0
 155  if (!class_exists('Error')) {
 156      class Error extends Exception
 157      {
 158      }
 159  
 160      class ArithmeticError extends Error
 161      {
 162      }
 163  
 164      class DivisionByZeroError extends ArithmeticError
 165      {
 166      }
 167  
 168      class TypeError extends Error
 169      {
 170      }
 171  }
 172  
 173  // the following was introduced in PHP 7.1.0
 174  if (!class_exists('ArgumentCountError')) {
 175      class ArgumentCountError extends TypeError
 176      {
 177      }
 178  }
 179  
 180  // the following was introduced in PHP 8.0.0
 181  if (!class_exists('ValueError')) {
 182      class ValueError extends Error
 183      {
 184      }
 185  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer