Java Decimal Round roundDouble(double num, int decimal)

Here you can find the source of roundDouble(double num, int decimal)

Description

round Double

License

Apache License

Declaration

public static String roundDouble(double num, int decimal) 

Method Source Code


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

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    public static String roundDouble(double num, int decimal) {
        String s = "0.";
        for (int i = 0; i < decimal; i++) {
            s += "0";
        }/*w  w  w  . ja v  a  2s .c o  m*/
        NumberFormat f = new DecimalFormat(s);
        s = f.format(num);
        return s;
    }
}

Related

  1. roundDecimal(double d, int radix)
  2. roundDecimalPlaces(final double input, final int decimalPlaces)
  3. roundDecimals(double d, int numOfDec)
  4. roundDistanceFromMeterToKm(final double distanceInMeter)
  5. roundDouble(double iVal)
  6. roundDouble(double numero, int ceros_a_la_derecha)
  7. roundDouble(Double val, int precision)
  8. roundedNumber(double inVal)
  9. RoundFractionalTons(double d)