Package ch.randelshofer.fastdoubleparser
Class JavaBigIntegerParser
java.lang.Object
ch.randelshofer.fastdoubleparser.JavaBigIntegerParser
Parses a
BigInteger value; the supported syntax is a super-set of
the syntax supported by BigInteger(String).
Syntax
Formal specification of the grammar:
- BigIntegerLiteral:
- [Sign] Digits
- [Sign]
0x[HexDigits]- [Sign]
0X[HexDigits]
- Digits:
- Digit {Digit}
- HexDigits:
- HexDigit {HexDigit}
- Digit:
- (one of)
0 1 2 3 4 5 6 7 8 9
- HexDigit:
- (one of)
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
Character lengths accepted by BigInteger(String):
Significand: 1 to 1,292,782,621 decimal digits.The resulting value must fit into
2^31 - 1bits. The decimal representation of the value2^31 - 1has 646,456,993 digits. Therefore an input String can only contain up to that many significant digits - the remaining digits must be leading zeroes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigIntegerparallelParseBigInteger(byte[] str) Convenience method for callingparallelParseBigInteger(byte[], int, int).static BigIntegerparallelParseBigInteger(byte[] str, int offset, int length) static BigIntegerparallelParseBigInteger(char[] str) Convenience method for callingparallelParseBigInteger(char[], int, int).static BigIntegerparallelParseBigInteger(char[] str, int offset, int length) static BigIntegerConvenience method for callingparallelParseBigInteger(CharSequence, int, int).static BigIntegerparallelParseBigInteger(CharSequence str, int offset, int length) Convenience method for callingparallelParseBigInteger(byte[], int, int).static BigIntegerparseBigInteger(byte[] str) Convenience method for callingparseBigInteger(byte[], int, int).static BigIntegerparseBigInteger(byte[] str, int offset, int length) static BigIntegerparseBigInteger(char[] str) Convenience method for callingparseBigInteger(char[], int, int).static BigIntegerparseBigInteger(char[] str, int offset, int length) static BigIntegerConvenience method for callingparseBigInteger(CharSequence, int, int).static BigIntegerparseBigInteger(CharSequence str, int offset, int length) Convenience method for callingparseBigInteger(byte[], int, int).
-
Method Details
-
parseBigInteger
Convenience method for callingparseBigInteger(CharSequence, int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parseBigInteger
Convenience method for callingparseBigInteger(byte[], int, int).- Parameters:
str- the string to be parsedoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-
parseBigInteger
Convenience method for callingparseBigInteger(byte[], int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parseBigInteger
Parses aBigIntegerLiteralfrom abyte-Array and converts it into aBigIntegervalue.See
JsonDoubleParserfor the syntax ofFloatingPointLiteral.- Parameters:
str- the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encodingoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-
parseBigInteger
Convenience method for callingparseBigInteger(char[], int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parseBigInteger
Parses aBigIntegerLiteralfrom achar-Array and converts it into aBigIntegervalue.See
JsonDoubleParserfor the syntax ofFloatingPointLiteral.- Parameters:
str- the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encodingoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Convenience method for callingparallelParseBigInteger(CharSequence, int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Convenience method for callingparallelParseBigInteger(byte[], int, int).- Parameters:
str- the string to be parsedoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Convenience method for callingparallelParseBigInteger(byte[], int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Parses aBigIntegerLiteralfrom abyte-Array and converts it into aBigIntegervalue.See
JsonDoubleParserfor the syntax ofFloatingPointLiteral.- Parameters:
str- the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encodingoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Convenience method for callingparallelParseBigInteger(char[], int, int).- Parameters:
str- the string to be parsed- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullNumberFormatException- if the string can not be parsed successfully
-
parallelParseBigInteger
Parses aBigIntegerLiteralfrom achar-Array and converts it into aBigIntegervalue.See
JsonDoubleParserfor the syntax ofFloatingPointLiteral.- Parameters:
str- the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encodingoffset- The index of the first character to parselength- The number of characters to parse- Returns:
- the parsed value
- Throws:
NullPointerException- if the string is nullIllegalArgumentException- if offset or length are illegalNumberFormatException- if the string can not be parsed successfully
-