Class NumberUtils
- java.lang.Object
-
- org.apache.commons.lang.math.NumberUtils
-
@Deprecated(since="2021-04-30") public class NumberUtils extends java.lang.Object
Deprecated.Commons Lang 2 is in maintenance mode. Commons Lang 3 should be used instead.Provides extra functionality for Java Number classes.
- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Byte
BYTE_MINUS_ONE
Deprecated.Reusable Byte constant for minus one.static java.lang.Byte
BYTE_ONE
Deprecated.Reusable Byte constant for one.static java.lang.Byte
BYTE_ZERO
Deprecated.Reusable Byte constant for zero.static java.lang.Double
DOUBLE_MINUS_ONE
Deprecated.Reusable Double constant for minus one.static java.lang.Double
DOUBLE_ONE
Deprecated.Reusable Double constant for one.static java.lang.Double
DOUBLE_ZERO
Deprecated.Reusable Double constant for zero.static java.lang.Float
FLOAT_MINUS_ONE
Deprecated.Reusable Float constant for minus one.static java.lang.Float
FLOAT_ONE
Deprecated.Reusable Float constant for one.static java.lang.Float
FLOAT_ZERO
Deprecated.Reusable Float constant for zero.static java.lang.Integer
INTEGER_MINUS_ONE
Deprecated.Reusable Integer constant for minus one.static java.lang.Integer
INTEGER_ONE
Deprecated.Reusable Integer constant for one.static java.lang.Integer
INTEGER_ZERO
Deprecated.Reusable Integer constant for zero.static java.lang.Long
LONG_MINUS_ONE
Deprecated.Reusable Long constant for minus one.static java.lang.Long
LONG_ONE
Deprecated.Reusable Long constant for one.static java.lang.Long
LONG_ZERO
Deprecated.Reusable Long constant for zero.static java.lang.Short
SHORT_MINUS_ONE
Deprecated.Reusable Short constant for minus one.static java.lang.Short
SHORT_ONE
Deprecated.Reusable Short constant for one.static java.lang.Short
SHORT_ZERO
Deprecated.Reusable Short constant for zero.
-
Constructor Summary
Constructors Constructor Description NumberUtils()
Deprecated.NumberUtils
instances should NOT be constructed in standard programming.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
compare(double lhs, double rhs)
Deprecated.Compares twodoubles
for order.static int
compare(float lhs, float rhs)
Deprecated.Compares two floats for order.static java.math.BigDecimal
createBigDecimal(java.lang.String str)
Deprecated.Convert aString
to aBigDecimal
.static java.math.BigInteger
createBigInteger(java.lang.String str)
Deprecated.Convert aString
to aBigInteger
.static java.lang.Double
createDouble(java.lang.String str)
Deprecated.Convert aString
to aDouble
.static java.lang.Float
createFloat(java.lang.String str)
Deprecated.Convert aString
to aFloat
.static java.lang.Integer
createInteger(java.lang.String str)
Deprecated.Convert aString
to aInteger
, handling hex and octal notations.static java.lang.Long
createLong(java.lang.String str)
Deprecated.Convert aString
to aLong
.static java.lang.Number
createNumber(java.lang.String str)
Deprecated.Turns a string value into a java.lang.Number.static boolean
isDigits(java.lang.String str)
Deprecated.Checks whether theString
contains only digit characters.static boolean
isNumber(java.lang.String str)
Deprecated.Checks whether the String a valid Java number.static byte
max(byte[] array)
Deprecated.Returns the maximum value in an array.static byte
max(byte a, byte b, byte c)
Deprecated.Gets the maximum of threebyte
values.static double
max(double[] array)
Deprecated.Returns the maximum value in an array.static double
max(double a, double b, double c)
Deprecated.Gets the maximum of threedouble
values.static float
max(float[] array)
Deprecated.Returns the maximum value in an array.static float
max(float a, float b, float c)
Deprecated.Gets the maximum of threefloat
values.static int
max(int[] array)
Deprecated.Returns the maximum value in an array.static int
max(int a, int b, int c)
Deprecated.Gets the maximum of threeint
values.static long
max(long[] array)
Deprecated.Returns the maximum value in an array.static long
max(long a, long b, long c)
Deprecated.Gets the maximum of threelong
values.static short
max(short[] array)
Deprecated.Returns the maximum value in an array.static short
max(short a, short b, short c)
Deprecated.Gets the maximum of threeshort
values.static byte
min(byte[] array)
Deprecated.Returns the minimum value in an array.static byte
min(byte a, byte b, byte c)
Deprecated.Gets the minimum of threebyte
values.static double
min(double[] array)
Deprecated.Returns the minimum value in an array.static double
min(double a, double b, double c)
Deprecated.Gets the minimum of threedouble
values.static float
min(float[] array)
Deprecated.Returns the minimum value in an array.static float
min(float a, float b, float c)
Deprecated.Gets the minimum of threefloat
values.static int
min(int[] array)
Deprecated.Returns the minimum value in an array.static int
min(int a, int b, int c)
Deprecated.Gets the minimum of threeint
values.static long
min(long[] array)
Deprecated.Returns the minimum value in an array.static long
min(long a, long b, long c)
Deprecated.Gets the minimum of threelong
values.static short
min(short[] array)
Deprecated.Returns the minimum value in an array.static short
min(short a, short b, short c)
Deprecated.Gets the minimum of threeshort
values.static int
stringToInt(java.lang.String str)
Deprecated.UsetoInt(String)
This method will be removed in Commons Lang 3.0static int
stringToInt(java.lang.String str, int defaultValue)
Deprecated.UsetoInt(String, int)
This method will be removed in Commons Lang 3.0static byte
toByte(java.lang.String str)
Deprecated.Convert aString
to abyte
, returningzero
if the conversion fails.static byte
toByte(java.lang.String str, byte defaultValue)
Deprecated.Convert aString
to abyte
, returning a default value if the conversion fails.static double
toDouble(java.lang.String str)
Deprecated.Convert aString
to adouble
, returning0.0d
if the conversion fails.static double
toDouble(java.lang.String str, double defaultValue)
Deprecated.Convert aString
to adouble
, returning a default value if the conversion fails.static float
toFloat(java.lang.String str)
Deprecated.Convert aString
to afloat
, returning0.0f
if the conversion fails.static float
toFloat(java.lang.String str, float defaultValue)
Deprecated.Convert aString
to afloat
, returning a default value if the conversion fails.static int
toInt(java.lang.String str)
Deprecated.Convert aString
to anint
, returningzero
if the conversion fails.static int
toInt(java.lang.String str, int defaultValue)
Deprecated.Convert aString
to anint
, returning a default value if the conversion fails.static long
toLong(java.lang.String str)
Deprecated.Convert aString
to along
, returningzero
if the conversion fails.static long
toLong(java.lang.String str, long defaultValue)
Deprecated.Convert aString
to along
, returning a default value if the conversion fails.static short
toShort(java.lang.String str)
Deprecated.Convert aString
to ashort
, returningzero
if the conversion fails.static short
toShort(java.lang.String str, short defaultValue)
Deprecated.Convert aString
to anshort
, returning a default value if the conversion fails.
-
-
-
Field Detail
-
LONG_ZERO
public static final java.lang.Long LONG_ZERO
Deprecated.Reusable Long constant for zero.
-
LONG_ONE
public static final java.lang.Long LONG_ONE
Deprecated.Reusable Long constant for one.
-
LONG_MINUS_ONE
public static final java.lang.Long LONG_MINUS_ONE
Deprecated.Reusable Long constant for minus one.
-
INTEGER_ZERO
public static final java.lang.Integer INTEGER_ZERO
Deprecated.Reusable Integer constant for zero.
-
INTEGER_ONE
public static final java.lang.Integer INTEGER_ONE
Deprecated.Reusable Integer constant for one.
-
INTEGER_MINUS_ONE
public static final java.lang.Integer INTEGER_MINUS_ONE
Deprecated.Reusable Integer constant for minus one.
-
SHORT_ZERO
public static final java.lang.Short SHORT_ZERO
Deprecated.Reusable Short constant for zero.
-
SHORT_ONE
public static final java.lang.Short SHORT_ONE
Deprecated.Reusable Short constant for one.
-
SHORT_MINUS_ONE
public static final java.lang.Short SHORT_MINUS_ONE
Deprecated.Reusable Short constant for minus one.
-
BYTE_ZERO
public static final java.lang.Byte BYTE_ZERO
Deprecated.Reusable Byte constant for zero.
-
BYTE_ONE
public static final java.lang.Byte BYTE_ONE
Deprecated.Reusable Byte constant for one.
-
BYTE_MINUS_ONE
public static final java.lang.Byte BYTE_MINUS_ONE
Deprecated.Reusable Byte constant for minus one.
-
DOUBLE_ZERO
public static final java.lang.Double DOUBLE_ZERO
Deprecated.Reusable Double constant for zero.
-
DOUBLE_ONE
public static final java.lang.Double DOUBLE_ONE
Deprecated.Reusable Double constant for one.
-
DOUBLE_MINUS_ONE
public static final java.lang.Double DOUBLE_MINUS_ONE
Deprecated.Reusable Double constant for minus one.
-
FLOAT_ZERO
public static final java.lang.Float FLOAT_ZERO
Deprecated.Reusable Float constant for zero.
-
FLOAT_ONE
public static final java.lang.Float FLOAT_ONE
Deprecated.Reusable Float constant for one.
-
FLOAT_MINUS_ONE
public static final java.lang.Float FLOAT_MINUS_ONE
Deprecated.Reusable Float constant for minus one.
-
-
Method Detail
-
stringToInt
public static int stringToInt(java.lang.String str)
Deprecated.UsetoInt(String)
This method will be removed in Commons Lang 3.0Convert a
String
to anint
, returningzero
if the conversion fails.If the string is
null
,zero
is returned.NumberUtils.stringToInt(null) = 0 NumberUtils.stringToInt("") = 0 NumberUtils.stringToInt("1") = 1
- Parameters:
str
- the string to convert, may be null- Returns:
- the int represented by the string, or
zero
if conversion fails
-
toInt
public static int toInt(java.lang.String str)
Deprecated.Convert a
String
to anint
, returningzero
if the conversion fails.If the string is
null
,zero
is returned.NumberUtils.toInt(null) = 0 NumberUtils.toInt("") = 0 NumberUtils.toInt("1") = 1
- Parameters:
str
- the string to convert, may be null- Returns:
- the int represented by the string, or
zero
if conversion fails - Since:
- 2.1
-
stringToInt
public static int stringToInt(java.lang.String str, int defaultValue)
Deprecated.UsetoInt(String, int)
This method will be removed in Commons Lang 3.0Convert a
String
to anint
, returning a default value if the conversion fails.If the string is
null
, the default value is returned.NumberUtils.stringToInt(null, 1) = 1 NumberUtils.stringToInt("", 1) = 1 NumberUtils.stringToInt("1", 0) = 1
- Parameters:
str
- the string to convert, may be nulldefaultValue
- the default value- Returns:
- the int represented by the string, or the default if conversion fails
-
toInt
public static int toInt(java.lang.String str, int defaultValue)
Deprecated.Convert a
String
to anint
, returning a default value if the conversion fails.If the string is
null
, the default value is returned.NumberUtils.toInt(null, 1) = 1 NumberUtils.toInt("", 1) = 1 NumberUtils.toInt("1", 0) = 1
- Parameters:
str
- the string to convert, may be nulldefaultValue
- the default value- Returns:
- the int represented by the string, or the default if conversion fails
- Since:
- 2.1
-
toLong
public static long toLong(java.lang.String str)
Deprecated.Convert a
String
to along
, returningzero
if the conversion fails.If the string is
null
,zero
is returned.NumberUtils.toLong(null) = 0L NumberUtils.toLong("") = 0L NumberUtils.toLong("1") = 1L
- Parameters:
str
- the string to convert, may be null- Returns:
- the long represented by the string, or
0
if conversion fails - Since:
- 2.1
-
toLong
public static long toLong(java.lang.String str, long defaultValue)
Deprecated.Convert a
String
to along
, returning a default value if the conversion fails.If the string is
null
, the default value is returned.NumberUtils.toLong(null, 1L) = 1L NumberUtils.toLong("", 1L) = 1L NumberUtils.toLong("1", 0L) = 1L
- Parameters:
str
- the string to convert, may be nulldefaultValue
- the default value- Returns:
- the long represented by the string, or the default if conversion fails
- Since:
- 2.1
-
toFloat
public static float toFloat(java.lang.String str)
Deprecated.Convert a
String
to afloat
, returning0.0f
if the conversion fails.If the string
str
isnull
,0.0f
is returned.NumberUtils.toFloat(null) = 0.0f NumberUtils.toFloat("") = 0.0f NumberUtils.toFloat("1.5") = 1.5f
- Parameters:
str
- the string to convert, may benull
- Returns:
- the float represented by the string, or
0.0f
if conversion fails - Since:
- 2.1
-
toFloat
public static float toFloat(java.lang.String str, float defaultValue)
Deprecated.Convert a
String
to afloat
, returning a default value if the conversion fails.If the string
str
isnull
, the default value is returned.NumberUtils.toFloat(null, 1.1f) = 1.0f NumberUtils.toFloat("", 1.1f) = 1.1f NumberUtils.toFloat("1.5", 0.0f) = 1.5f
- Parameters:
str
- the string to convert, may benull
defaultValue
- the default value- Returns:
- the float represented by the string, or defaultValue if conversion fails
- Since:
- 2.1
-
toDouble
public static double toDouble(java.lang.String str)
Deprecated.Convert a
String
to adouble
, returning0.0d
if the conversion fails.If the string
str
isnull
,0.0d
is returned.NumberUtils.toDouble(null) = 0.0d NumberUtils.toDouble("") = 0.0d NumberUtils.toDouble("1.5") = 1.5d
- Parameters:
str
- the string to convert, may benull
- Returns:
- the double represented by the string, or
0.0d
if conversion fails - Since:
- 2.1
-
toDouble
public static double toDouble(java.lang.String str, double defaultValue)
Deprecated.Convert a
String
to adouble
, returning a default value if the conversion fails.If the string
str
isnull
, the default value is returned.NumberUtils.toDouble(null, 1.1d) = 1.1d NumberUtils.toDouble("", 1.1d) = 1.1d NumberUtils.toDouble("1.5", 0.0d) = 1.5d
- Parameters:
str
- the string to convert, may benull
defaultValue
- the default value- Returns:
- the double represented by the string, or defaultValue if conversion fails
- Since:
- 2.1
-
toByte
public static byte toByte(java.lang.String str)
Deprecated.Convert a
String
to abyte
, returningzero
if the conversion fails.If the string is
null
,zero
is returned.NumberUtils.toByte(null) = 0 NumberUtils.toByte("") = 0 NumberUtils.toByte("1") = 1
- Parameters:
str
- the string to convert, may be null- Returns:
- the byte represented by the string, or
zero
if conversion fails - Since:
- 2.5
-
toByte
public static byte toByte(java.lang.String str, byte defaultValue)
Deprecated.Convert a
String
to abyte
, returning a default value if the conversion fails.If the string is
null
, the default value is returned.NumberUtils.toByte(null, 1) = 1 NumberUtils.toByte("", 1) = 1 NumberUtils.toByte("1", 0) = 1
- Parameters:
str
- the string to convert, may be nulldefaultValue
- the default value- Returns:
- the byte represented by the string, or the default if conversion fails
- Since:
- 2.5
-
toShort
public static short toShort(java.lang.String str)
Deprecated.Convert a
String
to ashort
, returningzero
if the conversion fails.If the string is
null
,zero
is returned.NumberUtils.toShort(null) = 0 NumberUtils.toShort("") = 0 NumberUtils.toShort("1") = 1
- Parameters:
str
- the string to convert, may be null- Returns:
- the short represented by the string, or
zero
if conversion fails - Since:
- 2.5
-
toShort
public static short toShort(java.lang.String str, short defaultValue)
Deprecated.Convert a
String
to anshort
, returning a default value if the conversion fails.If the string is
null
, the default value is returned.NumberUtils.toShort(null, 1) = 1 NumberUtils.toShort("", 1) = 1 NumberUtils.toShort("1", 0) = 1
- Parameters:
str
- the string to convert, may be nulldefaultValue
- the default value- Returns:
- the short represented by the string, or the default if conversion fails
- Since:
- 2.5
-
createNumber
public static java.lang.Number createNumber(java.lang.String str) throws java.lang.NumberFormatException
Deprecated.Turns a string value into a java.lang.Number.
First, the value is examined for a type qualifier on the end (
'f','F','d','D','l','L'
). If it is found, it starts trying to create successively larger types from the type specified until one is found that can represent the value.If a type specifier is not found, it will check for a decimal point and then try successively larger types from
Integer
toBigInteger
and fromFloat
toBigDecimal
.If the string starts with
0x
or-0x
, it will be interpreted as a hexadecimal integer. Values with leading0
's will not be interpreted as octal.Returns
null
if the string isnull
.This method does not trim the input string, i.e., strings with leading or trailing spaces will generate NumberFormatExceptions.
- Parameters:
str
- String containing a number, may be null- Returns:
- Number created from the string
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createFloat
public static java.lang.Float createFloat(java.lang.String str)
Deprecated.Convert a
String
to aFloat
.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
Float
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createDouble
public static java.lang.Double createDouble(java.lang.String str)
Deprecated.Convert a
String
to aDouble
.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
Double
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createInteger
public static java.lang.Integer createInteger(java.lang.String str)
Deprecated.Convert a
String
to aInteger
, handling hex and octal notations.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
Integer
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createLong
public static java.lang.Long createLong(java.lang.String str)
Deprecated.Convert a
String
to aLong
.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
Long
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createBigInteger
public static java.math.BigInteger createBigInteger(java.lang.String str)
Deprecated.Convert a
String
to aBigInteger
.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
BigInteger
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
createBigDecimal
public static java.math.BigDecimal createBigDecimal(java.lang.String str)
Deprecated.Convert a
String
to aBigDecimal
.Returns
null
if the string isnull
.- Parameters:
str
- aString
to convert, may be null- Returns:
- converted
BigDecimal
- Throws:
java.lang.NumberFormatException
- if the value cannot be converted
-
min
public static long min(long[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
min
public static int min(int[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
min
public static short min(short[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
min
public static byte min(byte[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
min
public static double min(double[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty- See Also:
IEEE754rUtils for a version of this method that handles NaN differently
-
min
public static float min(float[] array)
Deprecated.Returns the minimum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty- See Also:
IEEE754rUtils for a version of this method that handles NaN differently
-
max
public static long max(long[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
max
public static int max(int[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
max
public static short max(short[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
max
public static byte max(byte[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty
-
max
public static double max(double[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty- See Also:
IEEE754rUtils for a version of this method that handles NaN differently
-
max
public static float max(float[] array)
Deprecated.Returns the maximum value in an array.
- Parameters:
array
- an array, must not be null or empty- Returns:
- the minimum value in the array
- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty- See Also:
IEEE754rUtils for a version of this method that handles NaN differently
-
min
public static long min(long a, long b, long c)
Deprecated.Gets the minimum of three
long
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
-
min
public static int min(int a, int b, int c)
Deprecated.Gets the minimum of three
int
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
-
min
public static short min(short a, short b, short c)
Deprecated.Gets the minimum of three
short
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
-
min
public static byte min(byte a, byte b, byte c)
Deprecated.Gets the minimum of three
byte
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
-
min
public static double min(double a, double b, double c)
Deprecated.Gets the minimum of three
double
values.If any value is
NaN
,NaN
is returned. Infinity is handled.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
- See Also:
for a version of this method that handles NaN differently
-
min
public static float min(float a, float b, float c)
Deprecated.Gets the minimum of three
float
values.If any value is
NaN
,NaN
is returned. Infinity is handled.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the smallest of the values
- See Also:
for a version of this method that handles NaN differently
-
max
public static long max(long a, long b, long c)
Deprecated.Gets the maximum of three
long
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
-
max
public static int max(int a, int b, int c)
Deprecated.Gets the maximum of three
int
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
-
max
public static short max(short a, short b, short c)
Deprecated.Gets the maximum of three
short
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
-
max
public static byte max(byte a, byte b, byte c)
Deprecated.Gets the maximum of three
byte
values.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
-
max
public static double max(double a, double b, double c)
Deprecated.Gets the maximum of three
double
values.If any value is
NaN
,NaN
is returned. Infinity is handled.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
- See Also:
for a version of this method that handles NaN differently
-
max
public static float max(float a, float b, float c)
Deprecated.Gets the maximum of three
float
values.If any value is
NaN
,NaN
is returned. Infinity is handled.- Parameters:
a
- value 1b
- value 2c
- value 3- Returns:
- the largest of the values
- See Also:
for a version of this method that handles NaN differently
-
compare
public static int compare(double lhs, double rhs)
Deprecated.Compares two
doubles
for order.This method is more comprehensive than the standard Java greater than, less than and equals operators.
- It returns
-1
if the first value is less than the second. - It returns
+1
if the first value is greater than the second. - It returns
0
if the values are equal.
The ordering is as follows, largest to smallest:
- NaN
- Positive infinity
- Maximum double
- Normal positive numbers
- +0.0
- -0.0
- Normal negative numbers
- Minimum double (
-Double.MAX_VALUE
) - Negative infinity
Comparing
NaN
withNaN
will return0
.- Parameters:
lhs
- the firstdouble
rhs
- the seconddouble
- Returns:
-1
if lhs is less,+1
if greater,0
if equal to rhs
- It returns
-
compare
public static int compare(float lhs, float rhs)
Deprecated.Compares two floats for order.
This method is more comprehensive than the standard Java greater than, less than and equals operators.
- It returns
-1
if the first value is less than the second. - It returns
+1
if the first value is greater than the second. - It returns
0
if the values are equal.
The ordering is as follows, largest to smallest:
- NaN
- Positive infinity
- Maximum float
- Normal positive numbers
- +0.0
- -0.0
- Normal negative numbers
- Minimum float (
-Float.MAX_VALUE
) - Negative infinity
Comparing
NaN
withNaN
will return0
.- Parameters:
lhs
- the firstfloat
rhs
- the secondfloat
- Returns:
-1
if lhs is less,+1
if greater,0
if equal to rhs
- It returns
-
isDigits
public static boolean isDigits(java.lang.String str)
Deprecated.Checks whether the
String
contains only digit characters.Null
and empty String will returnfalse
.- Parameters:
str
- theString
to check- Returns:
true
if str contains only unicode numeric
-
isNumber
public static boolean isNumber(java.lang.String str)
Deprecated.Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the
0x
qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).Null
and empty String will returnfalse
.- Parameters:
str
- theString
to check- Returns:
true
if the string is a correctly formatted number
-
-