Java Fraction Format formatFloat(float num)

Here you can find the source of formatFloat(float num)

Description

format Float

License

Open Source License

Declaration

public static float formatFloat(float num) 

Method Source Code

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

import java.text.DecimalFormat;

public class Main {
    public static float formatFloat(float num) {
        float q = 0f;
        try {/*from ww w  .  j a v  a 2 s . c  o  m*/
            DecimalFormat df = new DecimalFormat("#.###");
            q = Float.parseFloat(df.format(num).replace(",", "."));

        } catch (Exception e) {
            e.printStackTrace();
        }
        return q;
    }
}

Related

  1. formatDoubleString(double data, String pattern)
  2. formatDoubleValue(String originalVal, Double valToProcess)
  3. formateNum(double num)
  4. formatFloat(double val1, double val2)
  5. formatFloat(float f, String format)
  6. formatFloat(float number)
  7. formatFloat(float number, int numberOfAfterDot)
  8. formatFloat(Float someFloat)
  9. FormatFloat(float value, int point)