Class Integers
- java.lang.Object
-
- org.apache.logging.log4j.core.util.Integers
-
public final class Integers extends java.lang.ObjectHelps deal with integers.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBITS_PER_INT
-
Constructor Summary
Constructors Modifier Constructor Description privateIntegers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intceilingNextPowerOfTwo(int x)Calculate the next power of 2, greater than or equal to x.static intparseInt(java.lang.String s)Parses the string argument as a signed decimal integer.static intparseInt(java.lang.String s, int defaultValue)Parses the string argument as a signed decimal integer.
-
-
-
Field Detail
-
BITS_PER_INT
private static final int BITS_PER_INT
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseInt
public static int parseInt(java.lang.String s, int defaultValue)Parses the string argument as a signed decimal integer.The input may be surrounded by whitespace.
- Parameters:
s- aStringcontaining theintrepresentation to parse, may benullor""defaultValue- the return value, usedefaultValueifsisnullor""- Returns:
- the integer value represented by the argument in decimal.
- Throws:
java.lang.NumberFormatException- if the string does not contain a parsable integer.
-
parseInt
public static int parseInt(java.lang.String s)
Parses the string argument as a signed decimal integer.- Parameters:
s- aStringcontaining theintrepresentation to parse, may benullor""- Returns:
- the integer value represented by the argument in decimal.
- Throws:
java.lang.NumberFormatException- if the string does not contain a parsable integer.
-
ceilingNextPowerOfTwo
public static int ceilingNextPowerOfTwo(int x)
Calculate the next power of 2, greater than or equal to x.From Hacker's Delight, Chapter 3, Harry S. Warren Jr.
- Parameters:
x- Value to round up- Returns:
- The next power of 2 from x inclusive
-
-