public class NumUtil extends Object
| Constructor and Description |
|---|
NumUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
divideAndRoundUp(int number,
int divisor) |
static long |
divideAndRoundUp(long number,
long divisor) |
static int |
getNbitNumberInt(int n) |
static long |
getNbitNumberLong(int n) |
static boolean |
is32bit(long x) |
static boolean |
isByte(int x)
Determines if a given
int value is the range of signed byte values. |
static boolean |
isByte(long l)
Determines if a given
long value is the range of signed byte values. |
static boolean |
isInt(long l)
Determines if a given
long value is the range of signed int values. |
static boolean |
isShiftCount(int x) |
static boolean |
isShort(int x)
Determines if a given
int value is the range of signed short values. |
static boolean |
isShort(long x)
Determines if a given
long value is the range of signed short values. |
static boolean |
isSignedNbit(int n,
int value) |
static boolean |
isSignedNbit(int n,
long value) |
static boolean |
isUByte(int x)
Determines if a given
int value is the range of unsigned byte values. |
static boolean |
isUByte(long x)
Determines if a given
long value is the range of unsigned byte values. |
static boolean |
isUInt(long x)
Determines if a given
long value is the range of unsigned int values. |
static boolean |
isUnsignedNbit(int n,
int value) |
static boolean |
isUnsignedNbit(int n,
long value) |
static boolean |
isUShort(int s) |
static boolean |
isUShort(long s) |
static int |
log2Ceil(int val) |
static long |
maxUnsigned(long a,
long b) |
static long |
maxValue(int bits)
Get the maximum value representable in a
bits bit signed integer. |
static long |
maxValueUnsigned(int bits)
Get the maximum value representable in a
bits bit unsigned integer. |
static long |
minUnsigned(long a,
long b) |
static long |
minValue(int bits)
Get the minimum value representable in a
bits bit signed integer. |
static int |
roundDown(int number,
int mod) |
static long |
roundDown(long number,
long mod) |
static int |
roundUp(int number,
int mod) |
static long |
roundUp(long number,
long mod) |
static byte |
safeToByte(int v) |
static int |
safeToInt(long v) |
static short |
safeToShort(int v) |
static byte |
safeToUByte(int v) |
static boolean |
sameSign(long a,
long b) |
public static boolean isShiftCount(int x)
public static boolean isUByte(int x)
int value is the range of unsigned byte values.public static boolean isByte(int x)
int value is the range of signed byte values.public static boolean isUByte(long x)
long value is the range of unsigned byte values.public static boolean isByte(long l)
long value is the range of signed byte values.public static boolean isUInt(long x)
long value is the range of unsigned int values.public static boolean isInt(long l)
long value is the range of signed int values.public static boolean isShort(int x)
int value is the range of signed short values.public static boolean isShort(long x)
long value is the range of signed short values.public static boolean isUShort(int s)
public static boolean isUShort(long s)
public static boolean is32bit(long x)
public static byte safeToUByte(int v)
public static byte safeToByte(int v)
public static short safeToShort(int v)
public static int safeToInt(long v)
public static int roundUp(int number,
int mod)
public static long roundUp(long number,
long mod)
public static int roundDown(int number,
int mod)
public static long roundDown(long number,
long mod)
public static int divideAndRoundUp(int number,
int divisor)
public static long divideAndRoundUp(long number,
long divisor)
public static int log2Ceil(int val)
public static boolean isUnsignedNbit(int n,
int value)
public static boolean isUnsignedNbit(int n,
long value)
public static boolean isSignedNbit(int n,
int value)
public static boolean isSignedNbit(int n,
long value)
public static int getNbitNumberInt(int n)
n - Number of bits that should be set to 1. Must be between 0 and 32 (inclusive).public static long getNbitNumberLong(int n)
n - Number of bits that should be set to 1. Must be between 0 and 64 (inclusive).public static long minValue(int bits)
bits bit signed integer.public static long maxValue(int bits)
bits bit signed integer.public static long maxValueUnsigned(int bits)
bits bit unsigned integer.public static long maxUnsigned(long a,
long b)
public static long minUnsigned(long a,
long b)
public static boolean sameSign(long a,
long b)