Skip to content

Commit

Permalink
Fix #490: regression in Double/Float conversion for "untyped" deseria…
Browse files Browse the repository at this point in the history
…lization
  • Loading branch information
cowtowncoder committed May 4, 2024
1 parent 2de31bf commit 0cf7855
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ private double _getDoubleValue() throws IOException {
@Override
public float getFloatValue() throws IOException {
_verifyIsNumberToken();
// 04-May-2024, tatu: May seem odd but Ion really does not
// expose 32-bit floats even if it MAY use them internally
// for encoding. So:
return (float) _getDoubleValue();
}

Expand Down Expand Up @@ -472,6 +475,7 @@ public NumberType getNumberType() throws IOException
return NumberType.BIG_INTEGER;
}
case FLOAT:
// 04-May-2024, tatu: Ion really does not expose 32-bit floats, so:
return NumberType.DOUBLE;
default:
}
Expand All @@ -489,7 +493,9 @@ public NumberTypeFP getNumberTypeFP() throws IOException
// 06-Jan-2024, tatu: Existing code maps Ion `FLOAT` into Java
// `float`. But code in `IonReader` suggests `Double` might
// be more accurate mapping... odd.
return NumberTypeFP.FLOAT32;
// 04-May-2024, tatu: Ion really does not expose 32-bit floats;
// must expose as 64-bit here too
return NumberTypeFP.DOUBLE64;
}
if (type == IonType.DECIMAL) {
// 06-Jan-2024, tatu: Seems like `DECIMAL` is expected to map
Expand Down
3 changes: 2 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ Active maintainers:
#487 (ion): Don't close IonParser on EOF to be compatible with `MappingIterator`
when source is an empty `InputStream`
(contributed by Yoann V)

#488 (ion): Upgrade `ion-java` to 1.11.7 (from 1.11.2)
#490 (ion) ION deserialization type change from Double to Float in 2.17.0
(reported by Florian H)

2.17.0 (12-Mar-2024)

Expand Down

0 comments on commit 0cf7855

Please sign in to comment.