[ 
https://issues.apache.org/jira/browse/AVRO-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16970890#comment-16970890
 ] 

ASF subversion and git services commented on AVRO-2620:
-------------------------------------------------------

Commit 96cfef55661fe2f29b89aa8b6813f94d06a62500 in avro's branch 
refs/heads/master from Ryan Skraba
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=96cfef5 ]

AVRO-2620: Use log power rule for max precision.


> Max precision on decimal/fixed LogicalType is wrong
> ---------------------------------------------------
>
>                 Key: AVRO-2620
>                 URL: https://issues.apache.org/jira/browse/AVRO-2620
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c++, java
>            Reporter: Ryan Skraba
>            Assignee: Ryan Skraba
>            Priority: Minor
>
> A decimal logical type with an underlying fixed bytes type is invalid if the 
> precision is greater than can be contained in the fixed bytes.  The 
> calculation for 
>  [max 
> precision|https://github.com/apache/avro/blob/a2098bd88361b5ff9298c462a2dccafbb0c2c508/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java#L262]
>  can return a wrong value when the fixed bytes size is greater than 128.
> For a fixed size of *129*, the {{Math.pow(2, 8 * size - 1)}} part of this 
> formula will return {{Double.INFINITY}}, and the max precision will be 
> considered {{Long.MAX_VALUE}}.  The expected value is 310 digits precision.
> We can apply the log power rule to avoid overflow, or some bit-twiddling 
> approximation (like 
> [java.math.BigDecimal|https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/math/BigDecimal.java#L3779]).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to