Example usage for java.lang Float floatValue

List of usage examples for java.lang Float floatValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public float floatValue() 

Source Link

Document

Returns the float value of this Float object.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    float f = -29.6f;
    Float f2 = new Float(f);
    System.out.println(f2.floatValue());
}

From source file:Main.java

public static void main(String[] args) {
    Float floatObject = new Float("10.01");
    float b = floatObject.floatValue();
    System.out.println("float:" + b);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Boolean refBoolean = new Boolean(true);
    boolean bool = refBoolean.booleanValue();

    Byte refByte = new Byte((byte) 123);
    byte b = refByte.byteValue();

    Character refChar = new Character('x');
    char c = refChar.charValue();

    Short refShort = new Short((short) 123);
    short s = refShort.shortValue();

    Integer refInt = new Integer(123);
    int i = refInt.intValue();

    Long refLong = new Long(123L);
    long l = refLong.longValue();

    Float refFloat = new Float(12.3F);
    float f = refFloat.floatValue();

    Double refDouble = new Double(12.3D);
    double d = refDouble.doubleValue();
}

From source file:Main.java

public static void main(String[] args) {

    Float fObj = new Float("10.50");
    byte b = fObj.byteValue();
    System.out.println(b);/*  w  w w .  j av a2s  . c  o m*/

    short s = fObj.shortValue();
    System.out.println(s);

    int i = fObj.intValue();
    System.out.println(i);

    float f = fObj.floatValue();
    System.out.println(f);

    double d = fObj.doubleValue();
    System.out.println(d);
}

From source file:Main.java

/**
 * unbox Float/*from  w  w w .  ja v a  2  s  . co m*/
 */
public static float unboxed(Float v) {
    return v == null ? 0 : v.floatValue();
}

From source file:Main.java

/**
 * Converts to primitive array./*from   w  w w.  j  a va2s  . co  m*/
 */
public static float[] values(Float[] array) {
    float[] dest = new float[array.length];
    for (int i = 0; i < array.length; i++) {
        Float v = array[i];
        if (v != null) {
            dest[i] = v.floatValue();
        }
    }
    return dest;
}

From source file:org.apache.fop.svg.ACIUtils.java

private static String toStyle(Float posture) {
    return ((posture != null) && (posture.floatValue() > 0.0)) ? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
}

From source file:cross.io.misc.Base64Util.java

/**
 * Returns a byte array representing the float values in the IEEE 754
 * floating-point "single format" bit layout.
 *
 * @param floatList a list of float values
 * @param bigEndian/*from   ww  w .ja v a2 s .c  om*/
 * @return a byte array representing the float values in the IEEE 754
 *         floating-point "single format" bit layout.
 */
public static byte[] floatListToByteArray(final List<Float> floatList, final boolean bigEndian) {
    final int floatListSize = floatList.size();
    final byte[] raw = new byte[floatListSize * 4];
    int jjj = 0;
    if (bigEndian) {
        for (int iii = 0; iii < floatListSize; iii++) {
            final Float aFloat = floatList.get(iii);
            final int ieee754 = Float.floatToIntBits(aFloat.floatValue());
            raw[jjj] = (byte) ((ieee754 >> 24) & 0xff);
            raw[jjj + 1] = (byte) ((ieee754 >> 16) & 0xff);
            raw[jjj + 2] = (byte) ((ieee754 >> 8) & 0xff);
            raw[jjj + 3] = (byte) ((ieee754) & 0xff);
            jjj += 4;
        }
    } else {
        for (int iii = 0; iii < floatListSize; iii++) {
            final Float aFloat = floatList.get(iii);
            final int ieee754 = Float.floatToIntBits(aFloat.floatValue());
            raw[jjj] = (byte) ((ieee754) & 0xff);
            raw[jjj + 1] = (byte) ((ieee754 >> 8) & 0xff);
            raw[jjj + 2] = (byte) ((ieee754 >> 16) & 0xff);
            raw[jjj + 3] = (byte) ((ieee754 >> 24) & 0xff);
            jjj += 4;
        }
    }
    return raw;
}

From source file:org.olat.ims.qti.export.QTIWordExport.java

private static void fetchPointsOfMultipleChoices(Element itemEl, ChoiceQuestion choice,
        Map<String, String> iinput) {
    Element resprocessingXML = itemEl.element("resprocessing");
    if (resprocessingXML != null) {
        List<?> respconditions = resprocessingXML.elements("respcondition");
        Map<String, Float> points = QTIEditHelper.fetchPoints(respconditions, choice.getType());
        for (Map.Entry<String, Float> entryPoint : points.entrySet()) {
            Float val = entryPoint.getValue();
            if (val != null && val.floatValue() > 0.0f) {
                iinput.put(entryPoint.getKey(), entryPoint.getKey());
            }//from   w ww .  jav  a2  s  .  c  om
        }
    }
}

From source file:com.ms.app.web.commons.tools.CurrencyFormattor.java

/**
 * //  ww w. j  av  a 2  s . co  m
 * 
 * @param fen
 * @return
 */
public static int yuanTofen(Float yuan) {
    if (yuan != null && yuan > 0) {
        // +0.001 java?
        return (int) (yuan.floatValue() * 100 + 0.001f);
    }
    return 0;
}