Class SafeMath

java.lang.Object
it.unimi.dsi.fastutil.SafeMath

public final class SafeMath extends 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 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)