Java Decimal Format getCorrectionValue(double basicValue, int digit)

Here you can find the source of getCorrectionValue(double basicValue, int digit)

Description

get Correction Value

License

Apache License

Declaration

public static double getCorrectionValue(double basicValue, int digit) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;

public class Main {

    public static double getCorrectionValue(double basicValue, int digit) {
        if (digit < 0)
            return basicValue;
        StringBuilder sb = new StringBuilder("#");
        if (digit > 0) {
            sb.append("0.");
            for (int i = 0; i < digit; i++) {
                sb.append("0");
            }//from   ww  w  .j  a  va 2s .  c  om
        }
        DecimalFormat format = new DecimalFormat(sb.toString());
        return Double.parseDouble(format.format(basicValue));
    }
}

Related

  1. decimalFormat(String pattern, double value)
  2. decimalFormatLabel(final long value, final long divider, final String unit)
  3. decimalPointTwo(Float input)
  4. decimalString(double d, boolean forceDigits)
  5. encodeDouble(double d)
  6. getDecimalFormat()
  7. getDecimalFormat()
  8. getDecimalFormat()
  9. getDecimalFormat()