Here you can find the source of round(double value, int precision)
Parameter | Description |
---|---|
value | a parameter |
precision | a parameter |
public static double round(double value, int precision)
//package com.java2s; //License from project: Apache License public class Main { /**//ww w. j a v a 2 s . c om * Round a double up or down by the given number of decimal places * * @param value * @param precision * @return */ public static double round(double value, int precision) { double factor = Math.pow(10, precision); double result = Math.round(value * factor) / factor; return result; } }