public class Numbers extends Object
| Constructor and Description |
|---|
Numbers() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isPowerOfTwo(long value)
Checks if
value is a power of 2. |
static int |
log2floor(long value)
Returns base 2 logarithm of the closest power of 2 that is less or equal to the
value. |
static short |
safeCastIntToShort(int value) |
static byte |
safeCastIntToUnsignedByte(int value) |
static short |
safeCastIntToUnsignedShort(int value) |
static byte |
safeCastLongToByte(long value) |
static int |
safeCastLongToInt(long value) |
static short |
safeCastLongToShort(long value) |
static int |
unsignedByteToInt(byte value) |
static int |
unsignedShortToInt(short value) |
public static boolean isPowerOfTwo(long value)
value is a power of 2.value - the value to checktrue if value is a power of 2.public static int log2floor(long value)
value.value - a positive long valuepublic static short safeCastIntToUnsignedShort(int value)
public static byte safeCastIntToUnsignedByte(int value)
public static int safeCastLongToInt(long value)
public static short safeCastLongToShort(long value)
public static short safeCastIntToShort(int value)
public static byte safeCastLongToByte(long value)
public static int unsignedShortToInt(short value)
public static int unsignedByteToInt(byte value)
Copyright © 2016–2021 MWARE SOLUTIONS. All rights reserved.