Here you can find the source of formatDigit(double value, int scale)
public static double formatDigit(double value, int scale)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; public class Main { public static double formatDigit(double value, int scale) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(scale, BigDecimal.ROUND_HALF_UP); double d = bd.doubleValue(); bd = null;/*from www. j a v a 2s .co m*/ return d; } }