List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:Main.java
public static void writeFloatAttribute(XmlSerializer out, String name, float value) throws IOException { out.attribute(null, name, Float.toString(value)); }
From source file:Main.java
/** * for printing boost only if not 1.0//from ww w . j a va 2 s . c om */ public static String boost(float boost) { if (boost != 1.0f) { return "^" + Float.toString(boost); } else return ""; }
From source file:Main.java
/** convert bitrate To String*/ public static String bitrateToString(int nBitr) { String s;/* w w w .j a v a2s. c o m*/ nBitr /= 1024; if (nBitr < 1024) { s = Integer.toString(nBitr) + "k"; } else { String str = Float.toString(nBitr / 1024.0f); int n = str.indexOf('.'); if (n >= 0 && n < str.length() - 2) str = str.substring(0, n + 2); s = (str + "m"); } return s; }
From source file:com.gmail.gkovalechyn.automaticevents.parsing.IFloat.java
@Override public String[] toArgs() { if (this.value == null) { this.value = (float) 0f; }/*from w w w . j a v a 2s . c o m*/ return new String[] { Float.toString((float) this.value) }; }
From source file:com.buffalokiwi.aerodrome.jet.Utils.java
/** * Round something with bankers rounding * @param d float to round/*from w w w. j a v a 2 s .co m*/ * @param decimalPlace places to round to * @return new float */ public static float round(float d, int decimalPlace, RoundingMode mode) { BigDecimal bd = new BigDecimal(Float.toString(d)); bd = bd.setScale(decimalPlace, mode); return bd.floatValue(); }
From source file:org.etudes.mneme.tool.FormatScoreDelegate.java
/** * Format a score to 2 decimal places, trimming ".0" if present. * /*from w w w .ja v a 2 s. c o m*/ * @param score * The score to format. * @return The formatted score */ protected static String formatScore(Float score) { if (score == null) return "-"; // round to two places String rv = Float.toString(Math.round(score * 100.0f) / 100.0f); // get rid of ".00" if (rv.endsWith(".00")) { rv = rv.substring(0, rv.length() - 3); } // get rid of ".0" if (rv.endsWith(".0")) { rv = rv.substring(0, rv.length() - 2); } return rv; }
From source file:org.muse.mneme.tool.FormatListGradeDelegate.java
/** * Format a score to 2 decimal places, trimming ".0" if present. * //from ww w .j a v a 2s .c o m * @param score * The score to format. * @return The formatted score */ protected static String formatScore(Float score) { if (score == null) return "-"; // round to a single place String rv = Float.toString(Math.round(score * 100.0f) / 100.0f); // get rid of ".00" if (rv.endsWith(".00")) { rv = rv.substring(0, rv.length() - 3); } // get rid of ".0" if (rv.endsWith(".0")) { rv = rv.substring(0, rv.length() - 2); } return rv; }
From source file:org.eyeseetea.malariacare.utils.Utils.java
public static String round(float base, int decimalPlace) { BigDecimal bd = new BigDecimal(Float.toString(base)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); if (decimalPlace == 0) return Integer.toString((int) bd.floatValue()); return Float.toString(bd.floatValue()); }
From source file:Main.java
public static String formatDS(float f) { String s = Float.toString(f); int l = s.length(); if (s.startsWith(".0", l - 2)) return s.substring(0, l - 2); int e = s.indexOf('E', l - 5); return e > 0 && s.startsWith(".0", e - 2) ? cut(s, e - 2, e) : s; }
From source file:org.opencloudengine.flamingo.mapreduce.util.MathUtils.java
/** * Scientific Notation? Standard Notation . * * @param value Float? Scientific Notation * @return Float? Standard Notation/* ww w . j a v a 2 s. c om*/ */ public static String convertScientificToStandard(float value) { return (new BigDecimal(Float.toString(value))).toPlainString(); }