/** * @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); }
private function floorModulo(Decimal $x, Decimal $y) : Decimal { return $x->sub($y->mul($x->div($y)->floor())); }