Java Float to String floatToString(float value)

Here you can find the source of floatToString(float value)

Description

convert float to String with two fractional digits

License

Open Source License

Parameter

Parameter Description
value a parameter

Declaration

public static String floatToString(float value) 

Method Source Code

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

public class Main {
    /**//from www . j  a  va  2s  . co m
     * convert float to String with two fractional digits
     * @param value
     * @return
     */
    public static String floatToString(float value) {
        if (Float.isNaN(value)) {
            return " --- ";
        }
        return String.format("%.2f", value);
    }
}

Related

  1. floatToString(float f, int precision)
  2. floatToString(float fValue)
  3. floatToString(Float num)
  4. floatToString(float val, int width)
  5. FloatToString(float value)
  6. floatToString(float value, int precision)
  7. floatToString(float value, String format)
  8. floatToString(float[] values)
  9. floatToString0(float value)