org.avis.util
Class Numbers

java.lang.Object
  extended by org.avis.util.Numbers

public final class Numbers
extends Object

General utility functions for messing with numbers.

Author:
Matthew Phillips

Method Summary
static Class<? extends Number> highestPrecision(Class<? extends Number> class1, Class<? extends Number> class2)
          Return the highest precision (class with the largest range) of two classes.
static Number upconvert(Number value, Class<? extends Number> type)
          Convert a numeric value upwards to a given type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

upconvert

public static Number upconvert(Number value,
                               Class<? extends Number> type)
Convert a numeric value upwards to a given type.

Parameters:
value - A numeric value.
type - The target type: either Long or Double.
Returns:
value upconverted to the target type.
Throws:
IllegalArgumentException - if type is not valid.

highestPrecision

public static Class<? extends Number> highestPrecision(Class<? extends Number> class1,
                                                       Class<? extends Number> class2)
Return the highest precision (class with the largest range) of two classes.

Throws:
IllegalArgumentException - if class1 or class2 is not a number.


Copyright © 2008 Matthew Phillips. All Rights Reserved.