Here you can find the source of round(double value, int decimals)
public static double round(double value, int decimals)
//package com.java2s; //License from project: Open Source License public class Main { private static final int DEFAULT_DECIMAL_PLACES = 3; public static double round(double value, int decimals) { int base = (int) Math.pow(10, decimals); return Math.floor(value * base) / base; }/* w ww . j a va 2 s. co m*/ public static double round(double value) { return round(value, DEFAULT_DECIMAL_PLACES); } }