Convert moneyness given as difference to par swap rate to moneyness in bp.
Uses the fixing times of the fix schedule to determine fractions.

@param moneyness as offset.
@return Moneyness in bp.
502983
private int convertMoneyness(double moneyness) {
		if(quotingConvention == QuotingConvention.PAYERVOLATILITYLOGNORMAL) {
			return (int) Math.round(moneyness * 100);
		} else if(quotingConvention == QuotingConvention.RECEIVERPRICE) {
			return - (int) Math.round(moneyness * 10000);
		} else {
			return (int) Math.round(moneyness * 10000);
		}
	}
249835
public static BasicAmountType getAmountForCurrency(final String currencyCodeName, final int amountInCents) {

		// We use the smallest existing currency unit for each currency,
		// so we need to calculate a divisor that can be used to transform
		// the value into the correct base used by PayPal..

		final Currency currency                          = Currency.getInstance(currencyCodeName);
		final CurrencyCodeType currencyCode              = CurrencyCodeType.fromValue(currency.getCurrencyCode());
		final double divisor                             = Math.pow(10, currency.getDefaultFractionDigits());
		final double calculatedAmount                    = ((double)amountInCents / divisor);

		return new BasicAmountType(currencyCode, Double.toString(calculatedAmount));

	}
986603
public static function roundMoneyValue($moneyValue, $targetDigits, $havingDigits)
    {
        $valueLength = strlen($moneyValue);
        $shouldRound = $targetDigits < $havingDigits && $valueLength - $havingDigits + $targetDigits > 0;

        if ($shouldRound && $moneyValue[$valueLength - $havingDigits + $targetDigits] >= 5) {
            $position = $valueLength - $havingDigits + $targetDigits;
            $addend = 1;

            while ($position > 0) {
                $newValue = (string) ((int) $moneyValue[$position - 1] + $addend);

                if ($newValue >= 10) {
                    $moneyValue[$position - 1] = $newValue[1];
                    $addend = $newValue[0];
                    --$position;
                    if ($position === 0) {
                        $moneyValue = $addend.$moneyValue;
                    }
                } else {
                    if ($moneyValue[$position - 1] === '-') {
                        $moneyValue[$position - 1] = $newValue[0];
                        $moneyValue = '-'.$moneyValue;
                    } else {
                        $moneyValue[$position - 1] = $newValue[0];
                    }

                    break;
                }
            }
        }

        return $moneyValue;
    }
169118
def normalise(self, to_currency):
        
        out = Money(currency=to_currency)
        for money in self._money_obs:
            out += converter.convert(money, to_currency)
        return Balance([out])
642410
public double getAndSet(double amount) {
    long v = value.getAndSet(Double.doubleToLongBits(amount));
    return Double.longBitsToDouble(v);
  }
1049986
def base_convert_money(amount, currency_from, currency_to):
    
    source = get_rate_source()

    # Get rate for currency_from.
    if source.base_currency != currency_from:
        rate_from = get_rate(currency_from)
    else:
        # If currency from is the same as base currency its rate is 1.
        rate_from = Decimal(1)

    # Get rate for currency_to.
    rate_to = get_rate(currency_to)

    if isinstance(amount, float):
        amount = Decimal(amount).quantize(Decimal('.000001'))

    # After finishing the operation, quantize down final amount to two points.
    return ((amount / rate_from) * rate_to).quantize(Decimal("1.00"))
648472
public void setExchangeRate(Currency otherCurrency, double amount) {
        Common.getInstance().getStorageHandler().getStorageEngine().setExchangeRate(this, otherCurrency, amount);
    }
1069064
@Override
    public FastMoney divideToIntegralValue(Number divisor) {
        if (isInfinityAndNotNaN(divisor)) {
            return new FastMoney(0L, getCurrency());
        }
        checkNumber(divisor);
        if (isOne(divisor)) {
            return this;
        }
        BigDecimal div = MoneyUtils.getBigDecimal(divisor);
        return new FastMoney(getBigDecimal().divideToIntegralValue(div), getCurrency(), false);
    }
439333
public static float evaluate(float mortgageAllowance, float cashDown)
    {
        float mortgageBalance = mortgageAllowance - cashDown;
        if(isInsufficient(mortgageAllowance, cashDown))
        {
            mortgageBalance = mortgageBalance * ( 1 + MIN_CASH_DOWN_FEE_RATIO );
        }
        
        return mortgageBalance;
    }
1107103
@Override
    public ExchangeRate getExchangeRate(MonetaryAmount amount) {
        return this.rateProvider.getExchangeRate(ConversionQueryBuilder
                .of(conversionQuery).setBaseCurrency(amount.getCurrency())
                .build());
        // return this.rateProvider.getExchangeRate(amount.getCurrency(),
        // getCurrency());
    }
82692
@Override
    public MonetaryAmountFactory<T> setNumber(Number number) {
        this.number = ConvertBigDecimal.of(number);
        return this;
    }
628352
@Override
    public MonetaryAmount apply(MonetaryAmount value) {
        Objects.requireNonNull(value, "Amount required.");
        // 1 extract BD value, round according the default fraction units
        int scale = this.context.getInt(SCALE_KEY);
        RoundingMode roundingMode = this.context.get(RoundingMode.class);
        BigDecimal num = value.getNumber().numberValue(BigDecimal.class).setScale(scale, roundingMode);
        // 2 evaluate minor units and remainder
        long minors = num.movePointRight(num.scale()).longValueExact();
        int minimalMinors = this.context.getInt(MINMINORS_KEY);
        long factor = minors / minimalMinors;
        long low = minimalMinors * factor;
        long high = minimalMinors * (factor + 1);
        if (minors - low > high - minors) {
            minors = high;
        } else if (minors - low < high - minors) {
            minors = low;
        } else {
            switch (roundingMode) {
                case HALF_UP:
                case UP:
                case HALF_EVEN:
                    minors = high;
                    break;
                default:
                    minors = low;
            }
        }
        return value.getFactory().setCurrency(value.getCurrency())
                .setNumber(BigDecimal.valueOf(minors).movePointLeft(scale)).create();
    }
80168
@Override
    public Money multiply(Number multiplicand) {
    	NumberVerifier.checkNoInfinityOrNaN(multiplicand);
        BigDecimal multiplicandBD = MoneyUtils.getBigDecimal(multiplicand);
        if (multiplicandBD.equals(BigDecimal.ONE)) {
            return this;
        }
        MathContext mc = MoneyUtils.getMathContext(monetaryContext, RoundingMode.HALF_EVEN);
        BigDecimal dec = this.number.multiply(multiplicandBD, mc);
        return new Money(dec, getCurrency(), monetaryContext);
    }
1196455
public function exchange(Money $money, $roundingMode = Money::ROUND_HALF_UP)
    {
        if ($money->getCurrency() != $this->getFromCurrency()) {
            throw new Exception\InvalidArgumentException('The Money has the wrong currency');
        }

        return $money->exchange($this->getToCurrency(), $this->getExchangeRate(), $roundingMode);
    }
859729
public static Comparator<? super MonetaryAmount> sortValuable(
			ExchangeRateProvider provider) {

		return (m1, m2) -> {
			CurrencyConversion conversion = provider.getCurrencyConversion(m1
					.getCurrency());
			return m1.compareTo(conversion.apply(m2));
		};
	}
730784
private double convertTenor(int maturityInMonths, int tenorInMonths) {
		Schedule schedule = fixMetaSchedule.generateSchedule(referenceDate, maturityInMonths, tenorInMonths);
		return schedule.getPayment(schedule.getNumberOfPeriods()-1);
	}
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);
    }