Java Decimal Round truncate(double d, int digits)

Here you can find the source of truncate(double d, int digits)

Description

truncate

License

Open Source License

Declaration

public static double truncate(double d, int digits) 

Method Source Code

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

import java.text.NumberFormat;

public class Main {
    public static double truncate(double d, int digits) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(digits);
        nf.setGroupingUsed(false);//ww w  .  j av a  2  s. com
        return Double.parseDouble(nf.format(d));
    }
}

Related

  1. roundTwoDecimals(Double d)
  2. roundTwoDecimals(double d)
  3. to_decimal(double v)
  4. toLimitDecimalFloatStr(double number, int newScale)
  5. toNumber(Double value, Double defaultValue)
  6. truncate(final double v, final int sigNumIndex)