public final class Ints extends Object
int primitives.| 限定符和类型 | 字段和说明 |
|---|---|
static int |
MAX_POWER_OF_TWO
The largest power of two that can be represented as an int.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
checkedCast(long value)
Returns the
int value that is equal to value, if possible. |
static int |
findNextPositivePowerOfTwo(int value)
Fast method of finding the next power of 2 greater than or equal to the supplied value.
|
static boolean |
isPowerOfTwo(int value)
Is this value a power of two.
|
static int |
roundToPowerOfTwo(int value)
Find the next larger positive power of two value up from the given value.
|
static int |
saturatedCast(long value)
Returns the
int nearest in value to value. |
public static final int MAX_POWER_OF_TWO
public static int checkedCast(long value)
int value that is equal to value, if possible.public static int saturatedCast(long value)
int nearest in value to value.public static int findNextPositivePowerOfTwo(int value)
<= 0 then 1 will be returned.
This method is not suitable for Integer.MIN_VALUE or numbers greater than 2^30.value - from which to search for next power of 2public static int roundToPowerOfTwo(int value)
value - from which next positive power of two will be foundpublic static boolean isPowerOfTwo(int value)
value - to be tested to see if it is a power of twoCopyright © 2021. All rights reserved.