Litipk\BigNumbers\Decimal::mul PHP Method

mul() public method

Multiplies two BigNumber objects
public mul ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal
$scale integer
return Decimal
    public function mul(Decimal $b, $scale = null)
    {
        self::paramsValidation($b, $scale);
        if ($b->isInfinite()) {
            return $b->mul($this);
        } elseif ($b->isZero()) {
            return DecimalConstants::Zero();
        }
        return self::fromString(bcmul($this->value, $b->value, $this->scale + $b->scale), $scale);
    }

Usage Example

コード例 #1
0
ファイル: Money.php プロジェクト: coolms/money
 /**
  * @param CurrencyInterface $targetCurrency
  * @param float|int $exchangeRate
  * @param int $roundingMode
  * @return Money
  */
 public function exchange(CurrencyInterface $targetCurrency, $exchangeRate, $roundingMode = self::ROUND_HALF_UP)
 {
     $this->assertRoundingMode($roundingMode);
     $exchangeRate = $this->castOperand($exchangeRate);
     $amount = $this->amount->mul($exchangeRate, $this->getInnerPrecision());
     return new static($amount, $targetCurrency);
 }
All Usage Examples Of Litipk\BigNumbers\Decimal::mul