Java Decimal Round roundThreeDecimals(double d)

Here you can find the source of roundThreeDecimals(double d)

Description

round Three Decimals

License

Open Source License

Declaration

public static double roundThreeDecimals(double d) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    public static double roundThreeDecimals(double d) {
        if (Double.isInfinite(d) || Double.isNaN(d)) {
            return d;
        }/*  ww w .  j a  v a 2 s.com*/
        DecimalFormat threeDForm = new DecimalFormat("#.###");
        return Double.valueOf(threeDForm.format(d));
    }
}

Related

  1. roundDouble(Double val, int precision)
  2. roundedNumber(double inVal)
  3. RoundFractionalTons(double d)
  4. roundNumDecimals(double d, int num)
  5. roundOffToTwoDecimal(double value)
  6. roundTwoDecimals(double d)
  7. roundTwoDecimals(double d)
  8. roundTwoDecimals(Double d)
  9. roundTwoDecimals(double d)