Package it.unimi.dsi.fastutil
Class SafeMath
java.lang.Object
it.unimi.dsi.fastutil.SafeMath
public final class SafeMath
extends java.lang.Object
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 Type Method Description static floatsafeDoubleToFloat(double value)static bytesafeIntToByte(int value)static charsafeIntToChar(int value)static shortsafeIntToShort(int value)static bytesafeLongToByte(long value)static charsafeLongToChar(long value)static intsafeLongToInt(long value)static shortsafeLongToShort(long value)Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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)
-