List of usage examples for java.lang Double byteValue
public byte byteValue()
From source file:Main.java
public static void main(String[] args) { Double doubleObject = new Double("10.01"); byte b = doubleObject.byteValue(); System.out.println("byte:" + b); }
From source file:Main.java
public static void main(String[] args) { Double dObj = new Double("10.50"); byte b = dObj.byteValue(); System.out.println(b);/*from w ww . jav a 2 s . c om*/ short s = dObj.shortValue(); System.out.println(s); int i = dObj.intValue(); System.out.println(i); float f = dObj.floatValue(); System.out.println(f); double d = dObj.doubleValue(); System.out.println(d); }
From source file:com.github.jessemull.microflex.util.DoubleUtil.java
/** * Converts a list of doubles to a list of bytes. * @param List<Double> list of doubles * @return list of bytes *///from w w w .ja va 2 s. c o m public static List<Byte> toByteList(List<Double> list) { List<Byte> byteList = new ArrayList<Byte>(); for (Double val : list) { if (!OverFlowUtil.byteOverflow(val)) { OverFlowUtil.overflowError(val); } byteList.add(val.byteValue()); } return byteList; }
From source file:com.projity.util.ClassUtils.java
/** * Convert a Double to an Object of a given class * @param value Double value to convert//w ww . ja v a2 s.c om * @param clazz Class the class to convert to * @return new object of the given class * @throws IllegalArgumentException if the value is not convertible to the class */ public static Object doubleToObject(Double value, Class clazz) { if (clazz == Boolean.class) return new Boolean(value.doubleValue() != 0.0); else if (clazz == Byte.class) return new Byte(value.byteValue()); else if (clazz == Short.class) return new Short(value.shortValue()); else if (clazz == Integer.class) return new Integer(value.intValue()); else if (clazz == Long.class) return new Long(value.longValue()); else if (clazz == Float.class) return new Float(value.floatValue()); else if (clazz == Double.class) return value; else if (clazz == Money.class) return Money.getInstance(value.doubleValue()); else if (clazz == Duration.class) return Duration.getInstanceFromDouble(value); else if (clazz == Work.class) return Work.getWorkInstanceFromDouble(value); throw new IllegalArgumentException("Class " + clazz + " cannot be converted from a Double"); }
From source file:org.apache.hadoop.hive.ql.udf.UDFToByte.java
public Byte evaluate(Double i) { if (i == null) { return null; } else {// w w w. j av a 2 s. co m return Byte.valueOf(i.byteValue()); } }