Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2046146 | 1.4.0 | Joe Darcy | P4 | Closed | Fixed | beta3 |
JDK-2046145 | 1.3.1_09 | Joe Darcy | P4 | Closed | Fixed | 09 |
JDK-2046144 | 1.2.2_16 | Joe Darcy | P4 | Resolved | Fixed | 16 |
Name: yyT116575 Date: 08/07/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
If the String passed to the BigInteger(String, int) constructor begins with "--
" (two minus signs), or "-0-" then a BigInteger object is created even though
such a String is badly formatted. Since BigDecimal(String) depends on the
above BigInteger constructor, BigDecimal also has this problem.
Example:
import java.math.BigInteger;
public class BigIntegerTest {
static BigInteger bi;
public static void main(String[] args) {
bi = new BigInteger("--1234567890");
System.out.println("--123456790 => " + bi);
bi = new BigInteger("-0-12345678");
System.out.println("-0-12345678 => " + bi);
}
}
I get the following output:
--1234567890 => -4294967295234567890
-0-12345678 => -4282621618
In fact, I've done some experimenting and I've only been able to get the
NumberFormatException to occur when there are no non-zero digits after the
second minus sign, or when radix is 10 and the number of non-zero digits
after the second minus sign is 9.
(Review ID: 129484)
======================================================================
- backported by
-
JDK-2046144 BigInteger(String, int) does not fail on multiple minus signs
- Resolved
-
JDK-2046145 BigInteger(String, int) does not fail on multiple minus signs
- Closed
-
JDK-2046146 BigInteger(String, int) does not fail on multiple minus signs
- Closed
- duplicates
-
JDK-4831095 BigDecimal constructor doesn't return exception with invalid format in 1.3.1_0X
- Closed
- relates to
-
JDK-5038425 BigInteger doesn't fail on invalid number format (-00-00).
- Resolved