Here you can find the source of getCorrectionValue(double basicValue, int digit)
public static double getCorrectionValue(double basicValue, int digit)
//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)); } }