public final class SafeMath
extends java.lang.Object
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.
Modifier and Type | Method and Description |
---|---|
static 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) |
public static char safeIntToChar(int value)
public static byte safeIntToByte(int value)
public static short safeIntToShort(int value)
public static char safeLongToChar(long value)
public static byte safeLongToByte(long value)
public static short safeLongToShort(long value)
public static int safeLongToInt(long value)
public static float safeDoubleToFloat(double value)