Here you can find the source of decimalPlaces(double value, int precision)
public static double decimalPlaces(double value, int precision)
//package com.java2s; //License from project: Apache License public class Main { public static double decimalPlaces(double value, int precision) { return (double) Math.round(value * Math.pow(10.0D, (double) precision)) / Math.pow(10.0D, (double) precision); }//from w w w . ja va 2s . c o m }