From 076909bd53551521ea76a7f5e02ef7882a38d10c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 15 Dec 2023 16:48:24 -0800 Subject: [PATCH] Fix `SmileParserBase.convertNumberToBigDecimal()` to avoid conversion to String --- .../jackson/dataformat/smile/SmileParserBase.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBase.java b/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBase.java index c1331e0a0..f2dc0a352 100644 --- a/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBase.java +++ b/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBase.java @@ -719,13 +719,14 @@ protected final void convertNumberToBigDecimal() throws IOException { // Note: this MUST start with more accurate representations, since we don't know which // value is the original one (others get generated when requested) - if ((_numTypesValid & (NR_DOUBLE | NR_FLOAT)) != 0) { - // Let's parse from String representation, to avoid rounding errors that - //non-decimal floating operations would incur - final String text = getText(); - streamReadConstraints().validateFPLength(text.length()); - _numberBigDecimal = NumberInput.parseBigDecimal( - text, isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)); + if ((_numTypesValid & NR_DOUBLE) != 0) { + // 15-Dec-2023, tatu: Should NOT try to use String representation + // since we already have decoded into double + _numberBigDecimal = new BigDecimal(_numberDouble); + } else if ((_numTypesValid & NR_FLOAT) != 0) { + // 15-Dec-2023, tatu: Should NOT try to use String representation + // since we already have decoded into float + _numberBigDecimal = new BigDecimal(_numberFloat); } else if ((_numTypesValid & NR_BIGINT) != 0) { _numberBigDecimal = new BigDecimal(_numberBigInt); } else if ((_numTypesValid & NR_LONG) != 0) {