A DESCRIPTION OF THE PROBLEM :
The documentation for the BigInteger(String) constructor says:
> The String representation consists of an optional minus sign followed by a sequence of one or more decimal digits.
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/math/BigInteger.html#%3Cinit%3E(java.lang.String)
However, it actually accepts not only a leading minus sign ('-') but also a leading plus sign ('+'). This is likely an oversight in the documentation because the BigInteger(String, int) constructor (to which the constructor delegates) explicitly mentions the leading plus sign.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Since "+5" is parsed successfully, the documentation should specify that a leading plus sign is allowed as well.
---------- BEGIN SOURCE ----------
new BigInteger("+5")
---------- END SOURCE ----------
The documentation for the BigInteger(String) constructor says:
> The String representation consists of an optional minus sign followed by a sequence of one or more decimal digits.
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/math/BigInteger.html#%3Cinit%3E(java.lang.String)
However, it actually accepts not only a leading minus sign ('-') but also a leading plus sign ('+'). This is likely an oversight in the documentation because the BigInteger(String, int) constructor (to which the constructor delegates) explicitly mentions the leading plus sign.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Since "+5" is parsed successfully, the documentation should specify that a leading plus sign is allowed as well.
---------- BEGIN SOURCE ----------
new BigInteger("+5")
---------- END SOURCE ----------
- csr for
-
JDK-8251235 Documentation of BigInteger(String) constructor does not mention leading plus
-
- Closed
-
- relates to
-
JDK-5017980 Allow signed positive integer to be parsed instead of a NumerFormatException
-
- Closed
-