Package it.unimi.dsi.fastutil
Class SafeMath
java.lang.Object
it.unimi.dsi.fastutil.SafeMath
Static utility method for safe conversions between primitive types.
Note that the methods of this class will throw an exception whenever a larger type cannot be exactly represented by a smaller type. This includes doubles within the range a float, but with too many significant bits.
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
safeDoubleToFloat
(double value) static byte
safeIntToByte
(int value) static char
safeIntToChar
(int value) static short
safeIntToShort
(int value) static byte
safeLongToByte
(long value) static char
safeLongToChar
(long value) static int
safeLongToInt
(long value) static short
safeLongToShort
(long value)
-
Method Details
-
safeIntToChar
public static char safeIntToChar(int value) -
safeIntToByte
public static byte safeIntToByte(int value) -
safeIntToShort
public static short safeIntToShort(int value) -
safeLongToChar
public static char safeLongToChar(long value) -
safeLongToByte
public static byte safeLongToByte(long value) -
safeLongToShort
public static short safeLongToShort(long value) -
safeLongToInt
public static int safeLongToInt(long value) -
safeDoubleToFloat
public static float safeDoubleToFloat(double value)
-