|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.string.NumberString
Converts strings to numbers.
Details: NumberString is a collection of functions that perform various conversions from String
s into numeric types.
Constructor Summary | |
NumberString()
|
Method Summary | |
static java.math.BigInteger |
toBigInteger(java.lang.String s)
Converts numeric string to BigInteger. |
static java.lang.Integer |
toSignedInt(java.lang.String s)
Decodes signed int. |
static java.lang.Integer |
toSignedInt(java.lang.String s,
int radix)
Safely converts String to int. |
static java.lang.Long |
toSignedLong(java.lang.String s)
Decodes signed long. |
static java.lang.Integer |
toUnsignedInt(java.lang.String s,
int radix)
Safely converts String to unsigned int. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NumberString()
Method Detail |
public static java.math.BigInteger toBigInteger(java.lang.String s)
Details: toBigInteger accepts numeric strings in the following form:
and safely converts them to BigInteger
s without threat of throwing an exception. (The BigInteger
constructors and methods can't do this.) If the supplied string is null
or not in any of the above forms, null
is returned. (BigInteger can't do this either!) In no case will an exception be thrown. (Nor this... :-)
s
- the stringpublic static final java.lang.Long toSignedLong(java.lang.String s)
Details: toSignedLong
is functionally the same as toBigInteger
, except that toSignedLong
attempts to decode a long
instead of a BigInteger
. Failure occurs if the string does not contain one of the forms recognized by toBigInteger
or if the string represents a number that is outside of the range of a signed long
. If the conversion is successful, a Long
representing the converted value is returned. Otherwise, null
is returned.
s
- the string to decodepublic static final java.lang.Integer toSignedInt(java.lang.String s)
Details: toSignedInt
is functionally the same as toBigInteger
, except that toSignedInt
attempts to decode an int
instead of a BigInteger
. Failure occurs if the string does not contain one of the forms recognized by toBigInteger
or if the string represents a number that is outside of the range of a signed int
. If the conversion is successful, an Integer
representing the converted value is returned. Otherwise, null
is returned.
s
- the string to decodepublic static final java.lang.Integer toSignedInt(java.lang.String s, int radix)
Details: toSignedInt
converts a numeric string to a signed 32-bit integer.
s
- the string to convertradix
- the radix in which the string's numeric value is expressedpublic static final java.lang.Integer toUnsignedInt(java.lang.String s, int radix)
Details: Converts a numeric string to an unsigned 32-bit integer. Note that while the data type returned represents a signed integer, the bits of that integer reflect an unsigned conversion.
s
- the string to convertradix
- the radix in which the string's numeric value is expressed
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |