Here you can find the source of round(double value, int places)
public static double round(double value, int places)
//package com.java2s; //License from project: Apache License public class Main { public static double round(double value, int places) { if (places < 0) throw new IllegalArgumentException(); long factor = (long) Math.pow(10, places); return (double) Math.round(value * factor) / factor; }/*from ww w . j a v a2s . c om*/ }