Java Fraction Format format(double number)

Here you can find the source of format(double number)

Description

format

License

Open Source License

Declaration

public static String format(double number) 

Method Source Code


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

import java.text.*;

public class Main {
    public static String format(double number) {
        DecimalFormat vf = new DecimalFormat("#00.#E0");
        String str = vf.format(number);
        str = str.replace("E0", " ");
        str = str.replace("E3", "k");
        str = str.replace("E6", "M");
        str = str.replace("E9", "G");
        str = str.replace("E12", "T");
        str = str.replace("E-3", "m");
        str = str.replace("E-6", "u");
        str = str.replace("E-9", "n");
        str = str.replace("E-12", "p");
        return str;
    }/*from w w w  . j  a v a2s.  c o  m*/
}

Related

  1. format(double num)
  2. format(Double num)
  3. format(Double num)
  4. format(double num, int n)
  5. format(double num, String pattern)
  6. format(double number)
  7. format(double number)
  8. format(double number, int digits)
  9. format(double number, String fmt)