Skip to content

Commit 9633143

Browse files
committed
Add release notes wrt #733, minor tweaks to Javadoc
1 parent e655e46 commit 9633143

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

release-notes/CREDITS-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ Doug Roper (htmldoug@github)
163163
(2.9.6)
164164
* Reported, Contributed test for #563: Async parser does not keep track of Array context properly
165165
(2.10.0)
166+
* Contributed #733: Add `StreamReadCapability.EXACT_FLOATS` to indicate whether parser reports exact
167+
floating-point values or not
168+
(2.14.0)
166169

167170
Alexander Eyers-Taylor (aeyerstaylor@github)
168171
* Reported #510: Fix ArrayIndexOutofBoundsException found by LGTM.com

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ JSON library.
2020
(contributed by Ilya G)
2121
#715: Allow TokenFilters to keep empty arrays and objects
2222
(contributed by Nik E)
23+
#733: Add `StreamReadCapability.EXACT_FLOATS` to indicate whether parser reports exact
24+
floating-point values or not
25+
(contributed Doug R)
2326

2427
2.13.2 (not yet released)
2528

src/main/java/com/fasterxml/jackson/core/StreamReadCapability.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,39 @@ public enum StreamReadCapability
5050
UNTYPED_SCALARS(false),
5151

5252
/**
53-
* Capability that indicates that data format may report floats
54-
* as a non-exact {@link com.fasterxml.jackson.core.JsonParser.NumberType},
55-
* due to prohibitively expensive parsing costs of determing the precision
56-
* upfront. For example, JSON numbers may be reported as
57-
* {@link com.fasterxml.jackson.core.JsonParser.NumberType#DOUBLE}
58-
* even if they would not fit into a 64-bit double without precision
59-
* loss. Methods like {@link JsonParser#getNumberValueExact()} or
60-
* {@link JsonParser#getValueAsString()} still report values without
53+
* Capability that indicates whether data format supports reporting of
54+
* accurate floating point values (with respect to reported numeric type,
55+
* {@link com.fasterxml.jackson.core.JsonParser.NumberType#DOUBLE}) or not.
56+
* This usually depends on whether format stores such values natively
57+
* (as IEEE binary FP formats for {@code java.lang.Float} and {@code java.lang.Double};
58+
* using some other value preserving presentation for {@code java.math.BigDecimal})
59+
* or not: most binary formats do, and most textual formats do not (at least for
60+
* {@code Float} and {@code Double}, specifically).
61+
*<p>
62+
* In case of JSON numbers (as well as for most if not all textual formats),
63+
* all floating-point numbers are represented simply by decimal (10-base)
64+
* textual representation and can only be represented accurately using
65+
* {@link java.math.BigDecimal}. But for performance reasons they may be
66+
* (depending on settings) be exposed as {@link java.lang.Double}s (that is,
67+
* {@link com.fasterxml.jackson.core.JsonParser.NumberType#DOUBLE}).
68+
* Note that methods like {@link JsonParser#getNumberValueExact()},
69+
* {@link JsonParser#getValueAsString()} and
70+
* {@link JsonParser#getDecimalValue()} report values without
6171
* precision loss.
62-
*
63-
* Capability is false for text formats JSON, but true for binary formats
72+
*<p>
73+
* The main intended use case is to let non-Jackson code to handle cases
74+
* where exact accuracy is necessary in a way that handling does not incur
75+
* unnecessary conversions across different formats: for example, when reading
76+
* binary format, simple access is essentially guaranteed to expose value exactly
77+
* as encoded by the format (as {@code float}, {@code double} or {@code BigDecimal}),
78+
* whereas for textual formats like JSON it is necessary to access value explicitly
79+
* as {@code BigDecimal} using {@code JsonParser#getDecimalValue}.
80+
*<p>
81+
* Capability is false for text formats like JSON, but true for binary formats
6482
* like Smile, MessagePack, etc., where type is precisely and inexpensively
65-
* signaled by a tag.
83+
* indicated by format.
84+
*
85+
* @since 2.14
6686
*/
6787
EXACT_FLOATS(false)
6888
;

0 commit comments

Comments
 (0)