public final class Integers
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
BITS_PER_INT |
Modifier | Constructor and Description |
---|---|
private |
Integers() |
Modifier and Type | Method and Description |
---|---|
static int |
ceilingNextPowerOfTwo(int x)
Calculate the next power of 2, greater than or equal to x.
|
static int |
parseInt(java.lang.String s)
Parses the string argument as a signed decimal integer.
|
static int |
parseInt(java.lang.String s,
int defaultValue)
Parses the string argument as a signed decimal integer.
|
private static final int BITS_PER_INT
public static int parseInt(java.lang.String s, int defaultValue)
s
- a String
containing the int
representation to parse, may be null
or ""
defaultValue
- the return value, use defaultValue
if s
is null
or ""
java.lang.NumberFormatException
- if the string does not contain a parsable integer.public static int parseInt(java.lang.String s)
s
- a String
containing the int
representation to parse, may be null
or ""
java.lang.NumberFormatException
- if the string does not contain a parsable integer.public static int ceilingNextPowerOfTwo(int x)
From Hacker's Delight, Chapter 3, Harry S. Warren Jr.
x
- Value to round up