clesaec commented on code in PR #2529:
URL: https://github.com/apache/avro/pull/2529#discussion_r1342568772


##########
lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java:
##########
@@ -208,7 +208,7 @@ public void writeLong(long n) throws IOException {
   @Override
   public void writeFloat(float f) throws IOException {
     parser.advance(Symbol.FLOAT);
-    out.writeNumber(f);
+    out.writeNumber(f + 0d);

Review Comment:
   We want to prevent the fact that in Java, 
`Float.toString(33.33000183105469f)` return "33.33" instead of the whole number.
   So, the cast to Double trigger Double.toString method instead which keep 
precision, and write 33.33000183105469.
   The "parser.advance(Symbol.FLOAT)" ensure we won't cast it to double at 
reading.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to