Java Decimal Round to_decimal(double v)

Here you can find the source of to_decimal(double v)

Description

Returns a decimal representation of a double (no scientific notation used).

License

Open Source License

Declaration

public static String to_decimal(double v) 

Method Source Code

//package com.java2s;
/*/*from   w w  w  . j a  va  2 s.  c o m*/
 * Carrot2 project.
 *
 * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski.
 * All rights reserved.
 *
 * Refer to the full license file "carrot2.LICENSE"
 * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */

import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    /**
     * Returns a decimal representation of a double 
     * (no scientific notation used).
     */
    public static String to_decimal(double v) {
        final NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
        nf.setMinimumFractionDigits(2);
        nf.setMaximumFractionDigits(4);
        return nf.format(v);
    }
}

Related

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