src/main/java/com/teamunify/i18n/I.java
public static double roundCurrency(double unroundedNumber) {
    int scale = getCurrencyFractionDigits();
    double divisor = scale > 0 ? (int) Math.pow(10, scale) : 1.0;
    // add in a fudge factor, or some boundary conditions round in the wrong direction
    return Math.round(unroundedNumber * divisor + 0.00001) / divisor;
  }
/**
   * Use the current locale's understanding of currency to round a double to the correct number of fractional digits.
   * <p/>
   * <p/>
   * <b>CAUTION:</b> Currency calculations must be done in a way that is consistent with accounting practices. Usually,
   * this means rounding at the end of a sequence of operations (so that rounding errors don't accumulate). The basic
   * rule is to round any currency amount that becomes visible to the user. So, for example:
   * <p/>
   * <pre>
   * double discount = 0.0123 * amount; // 1.23% discount
   * String userMessage = I.trf(&quot;You get a {0,currency} discount!&quot;, discount); // currency formatting will show it rounded
   * double roundedDiscount = I.roundCurrency(discount);
   * // now use the rounded number, since that is what they expect.
   * double price = price - roundedDiscount;
   * </pre>
   *
   * @param unroundedNumber The number to round
   * @return The same value, but rounded to the correct number of significant fractional digits for the locale's
   * currency.
   */
Use the current locale's understanding of currency to round a double to the correct number of fractional digits.


CAUTION: Currency calculations must be done in a way that is consistent with accounting practices. Usually,
this means rounding at the end of a sequence of operations (so that rounding errors don't accumulate). The basic
rule is to round any currency amount that becomes visible to the user. So, for example:


double discount = 0.0123 * amount; // 1.23% discount
String userMessage = I.trf("You get a {0,currency} discount!", discount); // currency formatting will show it rounded
double roundedDiscount = I.roundCurrency(discount);
now use the rounded number, since that is what they expect.
double price = price - roundedDiscount;


@param unroundedNumber The number to round
@return The same value, but rounded to the correct number of significant fractional digits for the locale's
currency.
Use the current locale ' s understanding of currency to round a double to the correct number of fractional digits . CAUTION : Currency calculations must be done in a way that is consistent with accounting practices . Usually this means rounding at the end of a sequence of operations ( so that rounding errors don ' t accumulate ) . The basic rule is to round any currency amount that becomes visible to the user . So for example : double discount = 0 . 0123 * amount ; // 1 . 23% discount String userMessage = I . trf ( " You get a { 0 currency } discount! " discount ) ; // currency formatting will show it rounded double roundedDiscount = I . roundCurrency ( discount ) ; now use the rounded number since that is what they expect . double price = price - roundedDiscount ; @param unroundedNumber The number to round @return The same value but rounded to the correct number of significant fractional digits for the locale ' s currency .
public static double roundCurrency(double unroundedNumber) {
    int scale = getCurrencyFractionDigits();
    double divisor = scale > 0 ? (int) Math.pow(10, scale) : 1.0;
    return Math.round(unroundedNumber * divisor + 0.00001) / divisor;
  }
public static double roundCurrency ( double unroundedNumber ) { int scale = getCurrencyFractionDigits ( ) ; double divisor = scale > 0 ? ( int ) Math . pow ( 10 , scale ) : 1.0 ; return Math . round ( unroundedNumber * divisor + 0.00001 ) / divisor ; }
Use the current locale's understanding of currency to round a double to the correct number of fractional digits.
Use the current locale ' s understanding of currency to round a double to the correct number of fractional digits .
// add in a fudge factor, or some boundary conditions round in the wrong direction