Java Fraction Format formatDouble(double number)

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

Description

format Double

License

Apache License

Declaration

public static double formatDouble(double number) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;

public class Main {
    public static double formatDouble(double number) {
        DecimalFormat fmt = new DecimalFormat("#.##");
        if (Double.isNaN(number)) {
            return Double.NaN;
        } else {//from   ww  w. j a va 2  s  .  c o  m
            return Double.parseDouble((fmt.format(number)));
        }
    }
}

Related

  1. formatDouble(double inVal, int inNumPlaces, boolean pad)
  2. formatDouble(double num)
  3. formatDouble(Double num)
  4. formatDouble(Double num)
  5. formatdouble(double number)
  6. formatDouble(double number)
  7. formatDouble(double number, int decimalDigits)
  8. formatDouble(double number, int integerDigits, int fractionDigits)
  9. formatDouble(double orig)