[ 
https://issues.apache.org/jira/browse/AVRO-3876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Christophe Le Saec reassigned AVRO-3876:
----------------------------------------


> JacksonUtils is not symmetric
> -----------------------------
>
>                 Key: AVRO-3876
>                 URL: https://issues.apache.org/jira/browse/AVRO-3876
>             Project: Apache Avro
>          Issue Type: Bug
>            Reporter: Christophe Le Saec
>            Assignee: Christophe Le Saec
>            Priority: Major
>
> For each json node, you should have
> {code:java}
> Object object = JacksonUtils.toObject(node);
> JsonNode node1 = JacksonUtils.toJsonNode(object);
> Assertions.assertEquals(node, node1);
> {code}
> But, that's not true for
> {code:java}
> JsonNodeFactory.instance.numberNode(33.33000183105469f);
> {code}
> where test give
> {noformat}
> org.opentest4j.AssertionFailedError: 
> Expected :33.33
> Actual   :33.33000183105469
> {noformat}
> because toObject method transform float to double and by default, 
> Float.toString method gives round values, as this code
> {code:java}
>     float x = 33.33000183105469f;
>     System.out.println("value float  = " + x);
>     System.out.println("value double = " + (double) x);
> {code}
> shows
> {noformat}
> value float  = 33.33
> value double = 33.33000183105469
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to