Java Decimal Format toScientific(double I, int digits)

Here you can find the source of toScientific(double I, int digits)

Description

to Scientific

License

Open Source License

Declaration

public static String toScientific(double I, int digits) 

Method Source Code


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

import java.text.DecimalFormat;

public class Main {
    public static String toScientific(double I, int digits) {
        StringBuffer strbuf = new StringBuffer("0.");
        for (int i = 0; i < digits; i++)
            strbuf.append("#");
        strbuf.append("E0");
        DecimalFormat df = new DecimalFormat(strbuf.toString());
        return (df.format(I));
    }//from  ww w  .  ja  v a2 s . com
}

Related

  1. toFix(double x, int dp)
  2. toFixedString(Locale locale, double value, int precision)
  3. toFmtDoubleStr(String doubleStr)
  4. toParse(double d)
  5. toPrecision(double I, int digits1, int digits2)
  6. toSplitDecimalString(Double num, int decimal)
  7. toStockPrice(double value)
  8. toString(double d)
  9. toString(double d)