JDK-6255285 : java.math.BigDecimal(String) fails if gets long exponent
Type:Bug
Component:core-libs
Sub-Component:java.math
Affected Version:5.0
Priority:P4
Status:Resolved
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2005-04-14
Updated:2012-03-23
Resolved:2005-04-30
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
java.math.BigDecimal(String) fails if gets long exponent, for example:
new BigDecimal("1.2e00000000000000000000000000001");
throws NumberFormatException.
###@###.### 2005-04-14 13:57:06 GMT
Comments
EVALUATION
This is a valid bug, but the user impact is very slight.
###@###.### 2005-04-16 03:47:32 GMT
16-04-2005
SUGGESTED FIX
src/share/classes/java/math>sccs sccsdiff -r1.54 -r1.55 BigDecimal.java
------- BigDecimal.java -------
341c341
< if (len <= 0 || len > 10) // no digits, or too long
---
> if (len <= 0) // no exponent digits
342a343,353
> // skip leading zeros in the exponent
> if (c < '1' || c > '9') { // if known nonzero ASCII digit, skip
> while ((c == '0' || (Character.digit(c, 10) == 0)) &&
> len > 1) {
> offset++;
> c = in[offset];
> len--;
> }
> }
> if (len > 10) // too many exponent digits
> throw new NumberFormatException();
###@###.### 2005-04-16 03:47:32 GMT