Here you can find the source of round(final double numberToRound, final int decimalPlaces)
public static double round(final double numberToRound, final int decimalPlaces)
//package com.java2s; //License from project: Apache License public class Main { public static double round(final double numberToRound, final int decimalPlaces) { final int roundedNumber = (int) Math.round(numberToRound * Math.pow(10, decimalPlaces)); return roundedNumber / Math.pow(10, decimalPlaces); }// w w w . j av a 2s . c o m }