Class JavaBigDecimalParser

java.lang.Object
ch.randelshofer.fastdoubleparser.JavaBigDecimalParser

public class JavaBigDecimalParser extends Object
Parses a BigDecimal value; the supported syntax is compatible with BigDecimal(String).

Syntax

Parses a BigDecimalString that is compatible with the grammar specified in BigDecimal(String).

Formal specification of the grammar:

BigDecimalString:
[Sign] Significand [Exponent]
Sign:
+
-
Significand:
IntegerPart . [FractionPart]
. FractionPart
IntegerPart
IntegerPart:
Digits
FractionPart:
Digits
DecExponent:
ExponentIndicator SignedInteger
ExponentIndicator:
e
E
SignedInteger:
[Sign] Digits
Digits:
Digit {Digit}

Character lengths accepted by BigInteger(String):

  • Significand: 1 to 1,292,782,621 decimal digits.

    The resulting value must fit into 2^31 - 1 bits. The decimal representation of the value 2^31 - 1 has 646,456,993 digits. Therefore an input String can only contain up to that many significant digits - the remaining digits must be leading zeroes.

  • SignedInteger in exponent: 1 to 10 digits. Exponents with more digits would yield to a BigDecimal.scale() that does not fit into a int-value.
  • BigDecimalString: 1 to 1,292,782,621+4+10=1,292,782,635 characters, e.g. "-1.234567890....12345E-2147483647".
Maximal input length supported by this parser:
  • BigDecimalString: 1,292,782,635 characters.

References:

Java SE 17 & JDK 17, JavaDoc, Class BigDecimal
docs.oracle.com