Here you can find the source of round(double amount)
public static double round(double amount)
//package com.java2s; //License from project: Apache License public class Main { public static double round(double amount) { double tmp1 = amount; long factor = (long) Math.pow(10, 2); tmp1 = tmp1 * factor;//from www . j a va 2 s .c o m long tmp = Math.round(Math.abs(tmp1)); amount = ((amount < 0 && tmp != 0) ? -1 : 1) * ((double) tmp / factor); String[] strArr = String.valueOf(amount).split("\\."); // // amount = Double.parseDouble(strArr[0] + "." // + (strArr.length > 1 ? strArr[1].substring(0, 2) : "00")); return amount; } }