phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Taylor (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-1825) Document supported range of DECIMAL and detect attempts to serialize an out of range BigDecimal
Date Wed, 08 Apr 2015 08:25:12 GMT

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

James Taylor updated PHOENIX-1825:
----------------------------------
    Summary: Document supported range of DECIMAL and detect attempts to serialize an out of
range BigDecimal  (was: PDecimal fails to store 1E-127)

> Document supported range of DECIMAL and detect attempts to serialize an out of range
BigDecimal
> -----------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1825
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1825
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Shuxiong Ye
>
> {code}
> BigDecimal v = BigDecimal.valueOf(1e-127);
> LiteralExpression literal;
> literal = LiteralExpression.newConstant(v, PDecimal.INSTANCE, SortOrder.ASC);
> ImmutableBytesWritable ptr = new ImmutableBytesWritable();
> literal.evaluate(null, ptr);
> System.out.println(v);                                  // 1.0E-127
> System.out.println(PDecimal.INSTANCE.toObject(ptr));    // 1E+129
> System.out.println(Double.MIN_VALUE);                   // 4.9E-324
> {code}
> The code above shows that when we put 1.0E-127 in PDecimal, it turns out to be 1E+129.
The reason is, in PDecimal, the length of exponent is 1 byte(see details in PDataType#toBytes
and PDataType#toBigDecimal), while in BigDecimal, the scale is a 4-byte int.
> As a reference, Double.MIN_VALUE equals 4.9e-324, which is the smallest positive nonzero
double value.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message