com.ge.research.utils
Class NumberUtils

java.lang.Object
  extended bycom.ge.research.utils.NumberUtils

public class NumberUtils
extends java.lang.Object

Simple class to help with Numbers and primitive number representation.

Version:
$Revision: 1.1 $ $Date: 2006/08/11 00:17:39 $
Author:
garbiras

Constructor Summary
NumberUtils()
           
 
Method Summary
static byte castToByte(double d)
          Casts a double value to a byte value, taking into account and eliminating overflow problems.
static int castToInt(double d)
          Casts a double value to a int value, taking into account and eliminating overflow problems.
static long castToLong(double d)
          Casts a double value to a long value, taking into account and eliminating overflow problems.
static short castToShort(double d)
          Casts a double value to a short value, taking into account and eliminating overflow problems.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtils

public NumberUtils()
Method Detail

castToShort

public static short castToShort(double d)
Casts a double value to a short value, taking into account and eliminating overflow problems.

Parameters:
d - the double to cast to a short
Returns:
The cast short. If the argument double is smaller than the Short.MIN_VALUE then the Short.MIN_VALUE is returned. If the argument double is larger than the Short.MAX_VALUE then the Short.MAX_VALUE is returned.

castToByte

public static byte castToByte(double d)
Casts a double value to a byte value, taking into account and eliminating overflow problems.

Parameters:
d - the double to cast to a byte
Returns:
The cast byte. If the argument double is smaller than the Byte.MIN_VALUE then the Byte.MIN_VALUE is returned. If the argument double is larger than the Byte.MAX_VALUE then the Byte.MAX_VALUE is returned.

castToLong

public static long castToLong(double d)
Casts a double value to a long value, taking into account and eliminating overflow problems.

Parameters:
d - the double to cast to a long
Returns:
The cast long. If the argument double is smaller than the Long.MIN_VALUE then the Long.MIN_VALUE is returned. If the argument double is larger than the Long.MAX_VALUE then the Long.MAX_VALUE is returned.

castToInt

public static int castToInt(double d)
Casts a double value to a int value, taking into account and eliminating overflow problems.

Parameters:
d - the double to cast to a short
Returns:
The cast int. If the argument double is smaller than the Integer.MIN_VALUE then the Int.MIN_VALUE is returned. If the argument double is larger than the Integer.MAX_VALUE then the Int.MAX_VALUE is returned.