Skip to content

Commit 076909b

Browse files
committed
Fix SmileParserBase.convertNumberToBigDecimal() to avoid conversion to String
1 parent 3401f2b commit 076909b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBase.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -719,13 +719,14 @@ protected final void convertNumberToBigDecimal() throws IOException
719719
{
720720
// Note: this MUST start with more accurate representations, since we don't know which
721721
// value is the original one (others get generated when requested)
722-
if ((_numTypesValid & (NR_DOUBLE | NR_FLOAT)) != 0) {
723-
// Let's parse from String representation, to avoid rounding errors that
724-
//non-decimal floating operations would incur
725-
final String text = getText();
726-
streamReadConstraints().validateFPLength(text.length());
727-
_numberBigDecimal = NumberInput.parseBigDecimal(
728-
text, isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
722+
if ((_numTypesValid & NR_DOUBLE) != 0) {
723+
// 15-Dec-2023, tatu: Should NOT try to use String representation
724+
// since we already have decoded into double
725+
_numberBigDecimal = new BigDecimal(_numberDouble);
726+
} else if ((_numTypesValid & NR_FLOAT) != 0) {
727+
// 15-Dec-2023, tatu: Should NOT try to use String representation
728+
// since we already have decoded into float
729+
_numberBigDecimal = new BigDecimal(_numberFloat);
729730
} else if ((_numTypesValid & NR_BIGINT) != 0) {
730731
_numberBigDecimal = new BigDecimal(_numberBigInt);
731732
} else if ((_numTypesValid & NR_LONG) != 0) {

0 commit comments

Comments
 (0)