List of utility methods to do Float Number Format
String | formatFloat(double num) format Float StringBuffer text = new StringBuffer(Double.toString(num)); int index = text.toString().indexOf("."); if (index < 0) { text.append("."); index = text.toString().indexOf("."); text.append("00"); text.delete(index + 3, text.length()); ... |
String | formatFloat(double number, int precision) Returns the specified double, formatted as a string, to n decimal places, as specified by precision. String text = Double.toString(number); if (precision >= text.length()) { return text; int start = text.indexOf(".") + 1; if (start == 0) return text; if (precision == 0) ... |
String | formatFloat(double value, int decimals) format Float String fmt = "%5." + String.valueOf(decimals) + "f"; return String.format(fmt, value); |
String | formatFloat(float f) format Float if (f == (int) f) return String.format("%d", (int) f); else return String.format("%s", f); |
float | formatFloat(float input, int numDecimals) format Float float m = (float) Math.pow(10, numDecimals); return Math.round(input * m) / m; |
String | formatFloat(float num, int width, int precision) format Float return formatReal(String.valueOf(num), width, precision);
|
String | formatFloat(float val) format Float String retval = Float.toString(val); return (retval); |
Float | formatFloat(String value) Checks if the value can safely be converted to a float primitive. if (value == null) { return null; try { return new Float(value); } catch (NumberFormatException e) { return null; |