Here you can find the source of roundDouble(double val, int precision)
Parameter | Description |
---|---|
val | double |
precision | int |
public static Double roundDouble(double val, int precision)
//package com.java2s; public class Main { /**/*from w w w . ja v a2s. c o m*/ * roundDouble. * * @param val double * @param precision int * @return Double */ public static Double roundDouble(double val, int precision) { double factor = Math.pow(10, precision); return Math.floor(val * factor + 0.5) / factor; } }