Here you can find the source of roundAtDecimals(double number, int deci)
Parameter | Description |
---|---|
Number | to round. |
Identifies | how many digits to round. |
public static double roundAtDecimals(double number, int deci)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www . ja v a 2s .c o m * @param Number to round. * @param Identifies how many digits to round. * @return Rounded Result. */ public static double roundAtDecimals(double number, int deci) { int decimal = deci * 10; number = number * decimal; Math.round(number); return number / decimal; } }