@@ -40,7 +40,47 @@ public abstract class JsonParser
40
40
*/
41
41
public enum NumberType {
42
42
INT , LONG , BIG_INTEGER , FLOAT , DOUBLE , BIG_DECIMAL
43
- };
43
+ }
44
+
45
+ /**
46
+ * Enumeration of possible physical Floating-Point types that
47
+ * underlying format uses. Used to indicate most accurate (and
48
+ * efficient) representation if known (if not known,
49
+ * {@link NumberTypeFP#UNKNOWN} is used).
50
+ *
51
+ * @since 2.17
52
+ */
53
+ public enum NumberTypeFP {
54
+ /**
55
+ * Special "mini-float" that some binary formats support.
56
+ */
57
+ FLOAT16 ,
58
+
59
+ /**
60
+ * Standard IEEE-754 single-precision 32-bit binary value
61
+ */
62
+ FLOAT32 ,
63
+
64
+ /**
65
+ * Standard IEEE-754 double-precision 64-bit binary value
66
+ */
67
+ DOUBLE64 ,
68
+
69
+ /**
70
+ * Unlimited precision, decimal (10-based) values
71
+ */
72
+ BIG_DECIMAL ,
73
+
74
+ /**
75
+ * Constant used when type is not known, or there is no specific
76
+ * type to match: most commonly used for textual formats like JSON
77
+ * where representation does not necessarily have single easily detectable
78
+ * optimal representation (for example, value {@code 0.1} has no
79
+ * exact binary representation whereas {@code 0.25} has exact representation
80
+ * in every binary type supported)
81
+ */
82
+ UNKNOWN ;
83
+ }
44
84
45
85
/**
46
86
* Default set of {@link StreamReadCapability}ies that may be used as
@@ -1715,7 +1755,7 @@ public Object getNumberValueDeferred() throws IOException {
1715
1755
* If current token is of type
1716
1756
* {@link JsonToken#VALUE_NUMBER_INT} or
1717
1757
* {@link JsonToken#VALUE_NUMBER_FLOAT}, returns
1718
- * one of {@link NumberType} constants; otherwise returns null.
1758
+ * one of {@link NumberType} constants; otherwise returns {@code null} .
1719
1759
*
1720
1760
* @return Type of current number, if parser points to numeric token; {@code null} otherwise
1721
1761
*
@@ -1724,6 +1764,23 @@ public Object getNumberValueDeferred() throws IOException {
1724
1764
*/
1725
1765
public abstract NumberType getNumberType () throws IOException ;
1726
1766
1767
+ /**
1768
+ * If current token is of type
1769
+ * {@link JsonToken#VALUE_NUMBER_FLOAT}, returns
1770
+ * one of {@link NumberTypeFP} constants; otherwise returns
1771
+ * {@link NumberTypeFP#UNKNOWN}.
1772
+ *
1773
+ * @return Type of current number, if parser points to numeric token; {@code null} otherwise
1774
+ *
1775
+ * @throws IOException for low-level read issues, or
1776
+ * {@link JsonParseException} for decoding problems
1777
+ *
1778
+ * @since 2.17
1779
+ */
1780
+ public NumberTypeFP getNumberTypeFP () throws IOException {
1781
+ return NumberTypeFP .UNKNOWN ;
1782
+ }
1783
+
1727
1784
/**
1728
1785
* Numeric accessor that can be called when the current
1729
1786
* token is of type {@link JsonToken#VALUE_NUMBER_INT} and
0 commit comments