Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

In this page you can find the example usage for java.lang Float valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:Main.java

public static Float celsiusToFahrenheit(float in) {
    return Float.valueOf((9.0f / 5.0f) * in + 32);
}

From source file:Main.java

public static float per(String string, String string2) {
    try {/*from   w w  w  . j  av a 2s .  c o m*/
        float retail = Float.valueOf(string);
        float tariff = Float.valueOf(string2);

        float result = (((tariff - retail) / tariff) * 100);
        //         Margin = ((T-R)/ T)*100%
        return Math.round(result * 100) / 100f;
    } catch (Exception e) {
    }
    return 0;
}

From source file:Main.java

public static float getAndroidVersion() {
    try {// w  ww . j ava  2 s. c om
        float f = Float.valueOf(Build.VERSION.RELEASE.substring(0, 2)).floatValue();
        return f;
    } catch (NumberFormatException localNumberFormatException) {
    }
    return 0.0F;
}

From source file:Main.java

/**
 * get android os version no/*from   w w w.j av a 2s  .  c o  m*/
 * @return
 */
public static float getAndroidVersion() {
    return Float.valueOf(android.os.Build.VERSION.RELEASE);
}

From source file:Main.java

public static float getRating(String rate) {
    if (rate != null) {
        if (rate.trim().length() == 2) {
            return Float.valueOf(rate) / 10;
        } else {/*w  ww.j  a va2s. co m*/
            return Float.valueOf(rate);
        }
    }
    return 0;
}

From source file:Main.java

public static String transferAVG_RTT(String oldValue) {
    String newValue = oldValue;/*from w ww  .ja v  a2  s.com*/
    float ov = Float.valueOf(oldValue);
    newValue = String.valueOf(Math.floor(ov + 0.5));
    return newValue;
}

From source file:Main.java

public static Float getFloat(String key) {
    return Float.valueOf(sp.getFloat(key, -1));
}

From source file:Main.java

public static String getFormattedValue(float f, String s) {
    return Html.fromHtml(String.format("%s %.2f", new Object[] { s, Float.valueOf(f) })).toString();
}

From source file:Main.java

public static float b2mb(int b) {
    String mb = String.format(Locale.getDefault(), "%.2f", (float) b / 1024 / 1024);
    return Float.valueOf(mb);
}

From source file:Main.java

public static String formatDecimal(String dcChgAmt) {
    if (isNumeric(dcChgAmt)) {
        return formatDecimal(Float.valueOf(dcChgAmt));
    }//from w w  w.  j a  v  a  2s  .  c o  m

    return dcChgAmt;
}