@@ -581,7 +581,7 @@ public boolean isNaN() {
581
581
/* Numeric accessors of public API
582
582
/**********************************************************
583
583
*/
584
-
584
+
585
585
@ Override
586
586
public Number getNumberValue () throws IOException
587
587
{
@@ -599,13 +599,43 @@ public Number getNumberValue() throws IOException
599
599
if ((_numTypesValid & NR_BIGINT ) != 0 ) {
600
600
return _numberBigInt ;
601
601
}
602
- // Shouldn't get this far but if we do
602
+ _throwInternal ();
603
+ }
604
+
605
+ // And then floating point types. But here optimal type
606
+ // needs to be big decimal, to avoid losing any data?
607
+ if ((_numTypesValid & NR_BIGDECIMAL ) != 0 ) {
603
608
return _numberBigDecimal ;
604
609
}
605
-
606
- /* And then floating point types. But here optimal type
607
- * needs to be big decimal, to avoid losing any data?
608
- */
610
+ if ((_numTypesValid & NR_DOUBLE ) == 0 ) { // sanity check
611
+ _throwInternal ();
612
+ }
613
+ return _numberDouble ;
614
+ }
615
+
616
+ // NOTE: mostly copied from above
617
+ @ Override
618
+ public Number getNumberValueExact () throws IOException
619
+ {
620
+ if (_currToken == JsonToken .VALUE_NUMBER_INT ) {
621
+ if (_numTypesValid == NR_UNKNOWN ) {
622
+ _parseNumericValue (NR_UNKNOWN );
623
+ }
624
+ if ((_numTypesValid & NR_INT ) != 0 ) {
625
+ return _numberInt ;
626
+ }
627
+ if ((_numTypesValid & NR_LONG ) != 0 ) {
628
+ return _numberLong ;
629
+ }
630
+ if ((_numTypesValid & NR_BIGINT ) != 0 ) {
631
+ return _numberBigInt ;
632
+ }
633
+ _throwInternal ();
634
+ }
635
+ // 09-Jul-2020, tatu: [databind#2644] requires we will retain accuracy, so:
636
+ if (_numTypesValid == NR_UNKNOWN ) {
637
+ _parseNumericValue (NR_BIGDECIMAL );
638
+ }
609
639
if ((_numTypesValid & NR_BIGDECIMAL ) != 0 ) {
610
640
return _numberBigDecimal ;
611
641
}
@@ -733,7 +763,7 @@ public BigDecimal getDecimalValue() throws IOException
733
763
/* Conversion from textual to numeric representation
734
764
/**********************************************************
735
765
*/
736
-
766
+
737
767
/**
738
768
* Method that will parse actual numeric value out of a syntactically
739
769
* valid number value. Type it will parse into depends on whether
0 commit comments