Class Integers
java.lang.Object
org.apache.logging.log4j.core.util.Integers
Helps deal with integers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
ceilingNextPowerOfTwo
(int x) Calculate the next power of 2, greater than or equal to x.static int
Parses the string argument as a signed decimal integer.static int
Parses the string argument as a signed decimal integer.
-
Method Details
-
parseInt
Parses the string argument as a signed decimal integer.The input may be surrounded by whitespace.
- Parameters:
s
- aString
containing theint
representation to parse, may benull
or""
defaultValue
- the return value, usedefaultValue
ifs
isnull
or""
- Returns:
- the integer value represented by the argument in decimal.
- Throws:
NumberFormatException
- if the string does not contain a parsable integer.
-
parseInt
Parses the string argument as a signed decimal integer.- Parameters:
s
- aString
containing theint
representation to parse, may benull
or""
- Returns:
- the integer value represented by the argument in decimal.
- Throws:
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
-