Java Double Number Round round(final double numberToRound, final int decimalPlaces)

Here you can find the source of round(final double numberToRound, final int decimalPlaces)

Description

round

License

Apache License

Declaration

public static double round(final double numberToRound, final int decimalPlaces) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double round(final double numberToRound, final int decimalPlaces) {
        final int roundedNumber = (int) Math.round(numberToRound * Math.pow(10, decimalPlaces));
        return roundedNumber / Math.pow(10, decimalPlaces);
    }// w  w  w  . j av a  2s . c o  m
}

Related

  1. round(double[] arr)
  2. round(double[] array, int decimals)
  3. round(double[][] data)
  4. round(final double num)
  5. round(final double num, final int prec)
  6. round(final double v)
  7. round(final double val, final int decimalPlaces)
  8. round(final double val, final int decimals)
  9. round(final Double value)