Package org.epics.util.number
Class UnsignedConversions
- java.lang.Object
-
- org.epics.util.number.UnsignedConversions
-
public class UnsignedConversions extends Object
Conversion utilities between unsigned primitives and standard Java primitives.Since we need all the combinations and since the standard libraries provide only some, we chose to re-implement all the cases here for readability and convenience. Note that the only conversions that are different are the widening from unsigned to signed. All other conversions are the same.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigIntegertoBigInteger(long unsignedValue)Converts an unsigned long to aBigInteger.static doubletoDouble(byte unsignedValue)Converts an unsigned byte to a double.static doubletoDouble(int unsignedValue)Converts an unsigned int to a double.static doubletoDouble(long unsignedValue)Converts an unsigned long to a double.static doubletoDouble(short unsignedValue)Converts an unsigned short to a double.static floattoFloat(byte unsignedValue)Converts an unsigned byte to a float.static floattoFloat(int unsignedValue)Converts an unsigned int to a float.static floattoFloat(long unsignedValue)Converts an unsigned long to a float.static floattoFloat(short unsignedValue)Converts an unsigned short to a float.static inttoInt(byte unsignedValue)Converts an unsigned byte to a int.static inttoInt(short unsignedValue)Converts an unsigned short to a int.static longtoLong(byte unsignedValue)Converts an unsigned byte to a long.static longtoLong(int unsignedValue)Converts an unsigned int to a long.static longtoLong(short unsignedValue)Converts an unsigned short to a long.static shorttoShort(byte unsignedValue)Converts an unsigned byte to a short.
-
-
-
Method Detail
-
toShort
public static short toShort(byte unsignedValue)
Converts an unsigned byte to a short.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toInt
public static int toInt(byte unsignedValue)
Converts an unsigned byte to a int.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toInt
public static int toInt(short unsignedValue)
Converts an unsigned short to a int.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toLong
public static long toLong(byte unsignedValue)
Converts an unsigned byte to a long.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toLong
public static long toLong(short unsignedValue)
Converts an unsigned short to a long.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toLong
public static long toLong(int unsignedValue)
Converts an unsigned int to a long.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toFloat
public static float toFloat(byte unsignedValue)
Converts an unsigned byte to a float.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toFloat
public static float toFloat(short unsignedValue)
Converts an unsigned short to a float.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toFloat
public static float toFloat(int unsignedValue)
Converts an unsigned int to a float.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toFloat
public static float toFloat(long unsignedValue)
Converts an unsigned long to a float.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toDouble
public static double toDouble(byte unsignedValue)
Converts an unsigned byte to a double.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toDouble
public static double toDouble(short unsignedValue)
Converts an unsigned short to a double.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toDouble
public static double toDouble(int unsignedValue)
Converts an unsigned int to a double.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toDouble
public static double toDouble(long unsignedValue)
Converts an unsigned long to a double.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
toBigInteger
public static BigInteger toBigInteger(long unsignedValue)
Converts an unsigned long to aBigInteger.- Parameters:
unsignedValue- unsigned value- Returns:
- the converted value
-
-