Example usage for java.lang Float byteValue

List of usage examples for java.lang Float byteValue

Introduction

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

Prototype

public byte byteValue() 

Source Link

Document

Returns the value of this Float as a byte after a narrowing primitive conversion.

Usage

From source file:Main.java

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

}

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);//from 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:com.splicemachine.derby.impl.load.HdfsImportIT.java

@Test
public void testImportNullFields() throws Exception {
    PreparedStatement ps = methodWatcher.prepareStatement(format("call SYSCS_UTIL.IMPORT_DATA(" + "'%s'," + // schema name
            "'%s'," + // table name
            "null," + // insert column list
            "'%s'," + // file path
            "','," + // column delimiter
            "'%s'," + // character delimiter
            "null," + // timestamp format
            "null," + // date format
            "null," + // time format
            "%d," + // max bad records
            "'%s'," + // bad record dir
            "null," + // has one line records
            "null)", // char set
            spliceSchemaWatcher.schemaName, TABLE_10, getResourceDirectory() + "null_field.csv", "\"", 0,
            BADDIR.getCanonicalPath()));
    ps.execute();//  w w w .jav  a2s  . co  m

    ResultSet rs = methodWatcher
            .executeQuery(format("select * from %s.%s", spliceSchemaWatcher.schemaName, TABLE_10));
    int count = 0;
    while (rs.next()) {
        Integer i = rs.getInt(1);
        Float j = rs.getFloat(2);
        String k = rs.getString(3);
        Timestamp l = rs.getTimestamp(4);
        Assert.assertEquals(i.byteValue(), 0);
        Assert.assertEquals(j.byteValue(), 0);
        Assert.assertNull("String failure " + k, k);
        Assert.assertNull("Timestamp failure " + l, l);
        count++;
    }
    Assert.assertTrue("import failed!" + count, count == 1);
}

From source file:org.apache.hadoop.hive.ql.udf.UDFToByte.java

public Byte evaluate(Float i) {
    if (i == null) {
        return null;
    } else {//from   ww w  .  j ava2  s  . c  o  m
        return Byte.valueOf(i.byteValue());
    }
}