@param Money    $money
@param Currency $counterCurrency
@param int      $roundingMode

@return Money
330836
public function convert(Money $money, Currency $counterCurrency, $roundingMode = Money::ROUND_HALF_UP)
    {
        $baseCurrency = $money->getCurrency();
        $ratio = $this->exchange->quote($baseCurrency, $counterCurrency)->getConversionRatio();

        $baseCurrencySubunit = $this->currencies->subunitFor($baseCurrency);
        $counterCurrencySubunit = $this->currencies->subunitFor($counterCurrency);
        $subunitDifference = $baseCurrencySubunit - $counterCurrencySubunit;

        $ratio = (string) Number::fromFloat($ratio)->base10($subunitDifference);

        $counterValue = $money->multiply($ratio, $roundingMode);

        return new Money($counterValue->getAmount(), $counterCurrency);
    }
492366
public MonetaryFormat roundingMode(RoundingMode roundingMode) {
        if (roundingMode == this.roundingMode)
            return this;
        else
            return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups,
                    shift, roundingMode, codes, codeSeparator, codePrefixed);
    }
177512
public function multiply($multiplier, $roundingMode = self::ROUND_HALF_UP, $precision = self::PRECISION_GAAP)
    {
        $this->assertRoundingMode($roundingMode);
        $multiplier = $this->castOperand($multiplier);
        $precision  = $this->castPrecision($precision);

        $amount = $this->amount->mul($multiplier, $this->getInnerPrecision() + 1);

        if (null === $roundingMode) {
            $amount = $amount->round($precision);
        } else {
            $amount = Math::bcround($amount, $precision, $roundingMode);
        }

        return $this->newInstance($amount);
    }
308712
@Override
    public RoundedMoney remainder(Number divisor) {
        MathContext mc = monetaryContext.get(MathContext.class);
        if(mc==null){
            mc = MathContext.DECIMAL64;
        }
        return new RoundedMoney(number.remainder(MoneyUtils.getBigDecimal(divisor), mc),
                currency, rounding);
    }
1288280
@Override
    public RoundedMoney remainder(Number divisor) {
        return new RoundedMoney(number.remainder(MoneyUtils.getBigDecimal(divisor), Optional.ofNullable(
                monetaryContext.get(MathContext.class)).orElse(MathContext.DECIMAL64)),
                currency, rounding);
    }
495682
public function amount($money)
    {
        if (null === $money) {
            return;
        }

        if (is_string($money) || $money < 0) {
            throw new InvalidArgumentException('Money amount must be a positive number.');
        }

        if ($this->getMoneyFormat() === 'cents') {
            return number_format($money, 0, '', '');
        }

        return sprintf('%.2f', number_format($money, 2, '.', '') / 100);
    }
905193
public function format(Money $money, $decPoint = ',', $thousandsSep = ' ')
    {
        return $this->moneyFormatter->formatMoney($money, $decPoint, $thousandsSep);
    }
785375
public function formatCurrency($value, $currency, $precision=2)
    {
        $newValue = trim($value, " \0\x0B$currency");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatCurrency');

        if ($newValue == round($newValue)) {
            // if no fraction digits available, don't show any
            $value = $this->formatNumberWithPattern($pattern, $newValue, 0, 0);
        } else {
            // show given count of fraction digits otherwise
            $value = $this->formatNumberWithPattern($pattern, $newValue, $precision, $precision);
        }

        return str_replace('¤', $currency, $value);
    }
664724
public function toSubunits($roundingMode = self::ROUND_HALF_UP)
    {
        $this->assertRoundingMode($roundingMode);

        $precision = $this->getPrecision();
        if (null === $roundingMode) {
            $amount = $this->amount->round($precision);
        } else {
            $amount = Math::bcround($this->amount, $precision, $roundingMode);
        }

        $subunitToUnit = $this->currency->getSubunitToUnit();
        if ($subunitToUnit > 1) {
            $subunitToUnit = Decimal::create($subunitToUnit, $precision);
            $amount = $amount->mul($subunitToUnit, $precision);
        }

        return $amount->asInteger();
    }
886662
public function subtract(MoneyContainer $money) : MoneyBag
    {
        foreach ($money->getAmounts() as $currencyCode => $amount) {
            $this->amounts[$currencyCode] = $this->getAmount($currencyCode)->minus($amount);
        }

        return $this;
    }
499267
@Override
    protected RoundedMoney create(Number number, CurrencyUnit currency, MonetaryContext monetaryContext) {
        return RoundedMoney.of(number, currency, MonetaryContext.from(monetaryContext, RoundedMoney.class));
    }
697062
public function divide(
        Money $money,
        $fraction
    ): Money {
        return new Money(
            $money->getAmount() / $fraction,
            $money->getCurrency()
        );
    }
341087
public function round($value, $currency = null)
    {
        return round($value, $this->precision, $this->mode);
    }
437838
public function convert(Currency $currency, $ratio, $roundingMode = self::ROUND_HALF_UP)
    {
        $this->currency = $currency;

        $this->assertOperand($ratio);
        $this->assertRoundingMode($roundingMode);

        if ($ratio < 1) {
            return $this->divide($ratio, $roundingMode);
        }

        return $this->multiply($ratio, $roundingMode);
    }
1128996
public function multiply(Real $multiplier, RoundingMode $rounding_mode = null)
    {
        if (null === $rounding_mode) {
            $rounding_mode = RoundingMode::HALF_UP();
        }

        $amount        = $this->getAmount()->toNative() * $multiplier->toNative();
        $roundedAmount = new Integer(round($amount, 0, $rounding_mode->toNative()));
        $result        = new self($roundedAmount, $this->getCurrency());

        return $result;
    }
63574
public static function parseByIntlLocalizedDecimal(
        $money,
        $forceCurrency,
        $locale = null,
        Currencies $currencies = null,
        $style = NumberFormatter::DECIMAL
    ) {
        $numberFormatter = new NumberFormatter($locale ?: static::getLocale(), $style);
        $parser = new IntlLocalizedDecimalParser($numberFormatter, $currencies ?: static::getCurrencies());

        return self::parseByParser($parser, $money, $forceCurrency);
    }
935880
public static function parse($money, $forceCurrency = null, $locale = null, Currencies $currencies = null)
    {
        return self::parseByIntl($money, $forceCurrency, $locale, $currencies);
    }