Skip to content

Commit

Permalink
try to avoid precision loss (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Apr 6, 2023
1 parent d0a998c commit dbf0f7c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2491,13 +2491,13 @@ public void copyCurrentEvent(JsonParser p) throws IOException
}
case ID_NUMBER_FLOAT:
{
NumberType n = p.getNumberType();
if (n == NumberType.BIG_DECIMAL) {
writeNumber(p.getDecimalValue());
} else if (n == NumberType.FLOAT) {
writeNumber(p.getFloatValue());
Number n = p.getNumberValueExact();
if (n instanceof Float) {
writeNumber((Float) n);
} else if (n instanceof BigDecimal) {
writeNumber((BigDecimal) n);
} else {
writeNumber(p.getDoubleValue());
writeNumber(n.doubleValue());
}
break;
}
Expand Down Expand Up @@ -2636,13 +2636,13 @@ protected void _copyCurrentContents(JsonParser p) throws IOException
}
case ID_NUMBER_FLOAT:
{
NumberType n = p.getNumberType();
if (n == NumberType.BIG_DECIMAL) {
writeNumber(p.getDecimalValue());
} else if (n == NumberType.FLOAT) {
writeNumber(p.getFloatValue());
Number n = p.getNumberValueExact();
if (n instanceof Float) {
writeNumber((Float) n);
} else if (n instanceof BigDecimal) {
writeNumber((BigDecimal) n);
} else {
writeNumber(p.getDoubleValue());
writeNumber(n.doubleValue());
}
break;
}
Expand Down

0 comments on commit dbf0f7c

Please sign in to comment.