Android Double Round round(double val, int numberOfDigitsAfterDecimal)

Here you can find the source of round(double val, int numberOfDigitsAfterDecimal)

Description

round

Declaration

public static double round(double val, int numberOfDigitsAfterDecimal) 

Method Source Code

//package com.java2s;

public class Main {
    public static double round(double val, int numberOfDigitsAfterDecimal) {
        double p = (float) Math.pow(10, numberOfDigitsAfterDecimal);
        val = val * p;
        double tmp = Math.floor(val);
        return (double) tmp / p;
    }//from  www  .  j  a  v a  2s. c o m
}

Related

  1. round(double d, int decimalPlace)
  2. round(double value)
  3. round(double d, int decimalPlace)
  4. round(double what, int howmuch)
  5. roundTwoDecimals(double d)
  6. round(double number, int decimal)
  7. convertDecimal(double d)