Skip to content

Commit a4f2086

Browse files
authored
[2.14 only] backport removal of BigDecimal to BigInt conversion (#990)
1 parent e77e28e commit a4f2086

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/main/java/com/fasterxml/jackson/core/io/NumberInput.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
public final class NumberInput
1010
{
11-
// numbers with more than these characters are better parsed with BigDecimalParser
12-
// parsing numbers with many digits in Java is slower than O(n)
13-
private final static int LARGE_INT_SIZE = 1250;
14-
1511
/**
1612
* Formerly used constant for a value that was problematic on certain
1713
* pre-1.8 JDKs.
@@ -398,10 +394,7 @@ public static BigDecimal parseBigDecimal(char[] ch) throws NumberFormatException
398394
* @throws NumberFormatException if string cannot be represented by a BigInteger
399395
* @since v2.14
400396
*/
401-
public static BigInteger parseBigInteger(String s) throws NumberFormatException {
402-
if (s.length() > LARGE_INT_SIZE) {
403-
return BigDecimalParser.parse(s).toBigInteger();
404-
}
397+
public static BigInteger parseBigInteger(final String s) throws NumberFormatException {
405398
return new BigInteger(s);
406399
}
407400
}

src/test/java/com/fasterxml/jackson/core/io/TestNumberInput.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,15 @@ public void testParseLongBigInteger()
4141
String test2000 = stringBuilder.toString();
4242
assertEquals(new BigInteger(test2000), NumberInput.parseBigInteger(test2000));
4343
}
44+
45+
public void testParseBigIntegerFailsWithENotation()
46+
{
47+
try {
48+
NumberInput.parseBigInteger("1e10");
49+
fail("expected NumberFormatException");
50+
} catch (NumberFormatException nfe) {
51+
// expected
52+
}
53+
}
4454
}
4555

0 commit comments

Comments
 (0)