Here you can find the source of getDecimal(double a)
public static double getDecimal(double a)
//package com.java2s; // LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, import java.math.BigDecimal; public class Main { public static double getDecimal(double a) { BigDecimal bd = new BigDecimal(a); bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); }/*from w w w .j av a 2 s . c o m*/ }