@Test public void newInstance() { doNewInstance(Byte.valueOf((byte) 42), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Short.valueOf((short) 42), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Short.valueOf((short) 420), Byte.class, Byte.valueOf((byte) 255)); doNewInstance(Short.valueOf((short) -42), Byte.class, Byte.valueOf((byte) 0)); doNewInstance(Integer.valueOf(42), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Integer.valueOf(420), Byte.class, Byte.valueOf((byte) 255)); doNewInstance(Integer.valueOf(-42), Byte.class, Byte.valueOf((byte) 0)); doNewInstance(Long.valueOf(42), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Long.valueOf(420), Byte.class, Byte.valueOf((byte) 255)); doNewInstance(Long.valueOf(-42), Byte.class, Byte.valueOf((byte) 0)); doNewInstance(Float.valueOf(42.0f), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Float.valueOf(420.0f), Byte.class, Byte.valueOf((byte) 255)); doNewInstance(Float.valueOf(-42.0f), Byte.class, Byte.valueOf((byte) 0)); doNewInstance(Double.valueOf(42.0d), Byte.class, Byte.valueOf((byte) 42)); doNewInstance(Double.valueOf(420.0d), Byte.class, Byte.valueOf((byte) 255)); doNewInstance(Double.valueOf(-42.0d), Byte.class, Byte.valueOf((byte) 0)); doNewInstance(Byte.valueOf((byte) 42), Short.class, Short.valueOf((short) 42)); doNewInstance(Short.valueOf((short) 42), Short.class, Short.valueOf((short) 42)); doNewInstance(Integer.valueOf(42), Short.class, Short.valueOf((short) 42)); doNewInstance(Integer.valueOf(Short.MAX_VALUE + 1), Short.class, Short.valueOf(Short.MAX_VALUE)); doNewInstance(Integer.valueOf(Short.MIN_VALUE - 1), Short.class, Short.valueOf(Short.MIN_VALUE)); doNewInstance(Long.valueOf(42), Short.class, Short.valueOf((short) 42)); doNewInstance(Long.valueOf(Short.MAX_VALUE + 1), Short.class, Short.valueOf(Short.MAX_VALUE)); doNewInstance(Long.valueOf(Short.MIN_VALUE - 1), Short.class, Short.valueOf(Short.MIN_VALUE)); doNewInstance(Float.valueOf(42.0f), Short.class, Short.valueOf((short) 42)); doNewInstance(Float.valueOf(Short.MAX_VALUE + 1), Short.class, Short.valueOf(Short.MAX_VALUE)); doNewInstance(Float.valueOf(Short.MIN_VALUE - 1), Short.class, Short.valueOf(Short.MIN_VALUE)); doNewInstance(Double.valueOf(42.0d), Short.class, Short.valueOf((short) 42)); doNewInstance(Double.valueOf(Short.MAX_VALUE + 1), Short.class, Short.valueOf(Short.MAX_VALUE)); doNewInstance(Double.valueOf(Short.MIN_VALUE - 1), Short.class, Short.valueOf(Short.MIN_VALUE)); doNewInstance(Byte.valueOf((byte) 42), Integer.class, Integer.valueOf(42)); doNewInstance(Short.valueOf((short) 42), Integer.class, Integer.valueOf(42)); doNewInstance(Integer.valueOf(42), Integer.class, Integer.valueOf(42)); doNewInstance(Long.valueOf(42), Integer.class, Integer.valueOf(42)); doNewInstance(Long.valueOf((long)Integer.MAX_VALUE + 1), Integer.class, Integer.valueOf(Integer.MAX_VALUE)); doNewInstance(Long.valueOf((long)Integer.MIN_VALUE - 1), Integer.class, Integer.valueOf(Integer.MIN_VALUE)); doNewInstance(Float.valueOf(42.0f), Integer.class, Integer.valueOf(42)); doNewInstance(Float.valueOf((float)Integer.MAX_VALUE + 1), Integer.class, Integer.valueOf(Integer.MAX_VALUE)); doNewInstance(Float.valueOf((float)Integer.MIN_VALUE - 1), Integer.class, Integer.valueOf(Integer.MIN_VALUE)); doNewInstance(Double.valueOf(42.0d), Integer.class, Integer.valueOf(42)); doNewInstance(Double.valueOf((double)Integer.MAX_VALUE + 1), Integer.class, Integer.valueOf(Integer.MAX_VALUE)); doNewInstance(Double.valueOf((double)Integer.MIN_VALUE - 1), Integer.class, Integer.valueOf(Integer.MIN_VALUE)); doNewInstance(Byte.valueOf((byte) 42), Float.class, Float.valueOf(42)); doNewInstance(Short.valueOf((short) 42), Float.class, Float.valueOf(42)); doNewInstance(Integer.valueOf(42), Float.class, Float.valueOf(42)); doNewInstance(Long.valueOf(42), Float.class, Float.valueOf(42)); doNewInstance(Float.valueOf(42.0f), Float.class, Float.valueOf(42)); doNewInstance(Double.valueOf(42.0d), Float.class, Float.valueOf(42)); doNewInstance(Double.valueOf((double)Float.MAX_VALUE + 1), Float.class, Float.valueOf(Float.MAX_VALUE)); doNewInstance(Double.valueOf((double)Float.MIN_VALUE - 1), Float.class, Float.valueOf(Float.MIN_VALUE)); }
public static Number newInstance(Number number, Class<? extends Number> clazz) { ClassInfo ci = ClassInfo.get(clazz); return newInstance(number, ci, false); }
NumberOperations { public static Number newInstance(Number number, Class<? extends Number> clazz) { ClassInfo ci = ClassInfo.get(clazz); return newInstance(number, ci, false); } }
NumberOperations { public static Number newInstance(Number number, Class<? extends Number> clazz) { ClassInfo ci = ClassInfo.get(clazz); return newInstance(number, ci, false); }  }
NumberOperations { public static Number newInstance(Number number, Class<? extends Number> clazz) { ClassInfo ci = ClassInfo.get(clazz); return newInstance(number, ci, false); }  static Number add(Number n1, Number n2); static Number subtract(Number n1, Number n2); static Number multiply(Number n1, Number n2); static Number divide(Number n1, Number n2); static int compare(Number n1, Number n2); static float getFloatTolerance(); static void setFloatTolerance(float tol); static double getDoubleTolerance(); static void setFloatTolerance(double tol); static int intValue(Number number); static long longValue(Number number); static float floatValue(Number number); static double doubleValue(Number number); static Number copy(Number number); static Number newInstance(Number number, Class<? extends Number> clazz); static Number castNumber(Number number, Class<? extends Number> clazz); static Class<? extends Number> highestClass(Number ...numbers); static Class<? extends Number> lowestClass(Number ...numbers); }
NumberOperations { public static Number newInstance(Number number, Class<? extends Number> clazz) { ClassInfo ci = ClassInfo.get(clazz); return newInstance(number, ci, false); }  static Number add(Number n1, Number n2); static Number subtract(Number n1, Number n2); static Number multiply(Number n1, Number n2); static Number divide(Number n1, Number n2); static int compare(Number n1, Number n2); static float getFloatTolerance(); static void setFloatTolerance(float tol); static double getDoubleTolerance(); static void setFloatTolerance(double tol); static int intValue(Number number); static long longValue(Number number); static float floatValue(Number number); static double doubleValue(Number number); static Number copy(Number number); static Number newInstance(Number number, Class<? extends Number> clazz); static Number castNumber(Number number, Class<? extends Number> clazz); static Class<? extends Number> highestClass(Number ...numbers); static Class<? extends Number> lowestClass(Number ...numbers); static final float DEFAULT_FLOAT_TOL; static final double DEFAULT_DOUBLE_TOL; }