NumberUtils { public static Double divideForExchangeRates(Double dividend, Double divisor) { Double double1 = (Double.valueOf(0d).equals(divisor)) ? Double.valueOf(0d) : divide(dividend, divisor, 10); return ensureExchangeRateMinMax(double1); }  static Double neg(Double value); static Double getStringToDoubleNonRounded(Locale locale,
                                                     String stringToBeParsed); static Double getStringToDoubleRounded(Locale locale,
            String stringToBeParsed); static Double divide(Double dividend, Integer divisor); static DivisionResult divideWithLoss(Double dividend,
            Integer divisor, boolean resultToBeNegative); static Double multiply(Double factorA, Integer factorB); static Double multiply(Double factorA, Double factorB); static Double divide(Double dividend, Double divisor); static Double divideForExchangeRates(Double dividend, Double divisor); static Double ensureExchangeRateMinMax(Double double1); static Double ensureAmountMinMax(Double double1); static boolean isExceedingAmountLimit(Double double1); static Double invertExchangeRateDouble(Double exchangeRate); static Double divide(Double dividend, Double divisor, int scale); static double round(double nonRounded);  }
@Test public void testDivisionForExchangeRates() { Assert.assertEquals(Double.valueOf(0.6666666667d), NumberUtils.divideForExchangeRates(1d, 1.5d)); Assert.assertEquals(Double.valueOf(0.7584951456d), NumberUtils.divideForExchangeRates(1d, 1.3184d)); Assert.assertEquals(Double.valueOf(1.3183915623d), NumberUtils.divideForExchangeRates(1d, 0.7585d)); Assert.assertEquals(Double.valueOf(0.9999180167d), NumberUtils.divideForExchangeRates(1d, 1.00008199d)); Assert.assertEquals(Double.valueOf(0.8100051840d), NumberUtils.divideForExchangeRates(1d, 1.23456d)); Assert.assertEquals(Double.valueOf(10.0d), NumberUtils.divideForExchangeRates(1d, 0.1d)); Assert.assertEquals(Double.valueOf(1.0d), NumberUtils.divideForExchangeRates(1d, 1.0d)); }
@Test public void testDivisionForExchangeRatesMinMaxForEntry() { Assert.assertEquals(Double.valueOf(9999999999.999d), NumberUtils.divideForExchangeRates(1d, 0.0000000001d)); Assert.assertEquals(Double.valueOf(0.0000000001d), NumberUtils.divideForExchangeRates(1d, 9999999999.999d)); Assert.assertEquals(Double.valueOf(0.0010010010d), NumberUtils.divideForExchangeRates(1d, 999.0000000001d)); Assert.assertEquals(Double.valueOf(0.000000001d), NumberUtils.divideForExchangeRates(1d, 1000000000.999d)); }
@Test public void testDivisionForExchangeRatesFreaky() { Assert.assertEquals(Double.valueOf(1d), NumberUtils.divideForExchangeRates(1d, 1d)); Assert.assertEquals(Double.valueOf(0d), NumberUtils.divideForExchangeRates(1d, 0d)); }