Return-Path: X-Original-To: apmail-phoenix-dev-archive@minotaur.apache.org Delivered-To: apmail-phoenix-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 69BF617F23 for ; Wed, 8 Apr 2015 08:25:43 +0000 (UTC) Received: (qmail 56123 invoked by uid 500); 8 Apr 2015 08:25:33 -0000 Delivered-To: apmail-phoenix-dev-archive@phoenix.apache.org Received: (qmail 56080 invoked by uid 500); 8 Apr 2015 08:25:33 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 56043 invoked by uid 99); 8 Apr 2015 08:25:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2015 08:25:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Apr 2015 08:25:32 +0000 Received: (qmail 52397 invoked by uid 99); 8 Apr 2015 08:25:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2015 08:25:12 +0000 Date: Wed, 8 Apr 2015 08:25:12 +0000 (UTC) From: "James Taylor (JIRA)" To: dev@phoenix.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (PHOENIX-1825) Document supported range of DECIMAL and detect attempts to serialize an out of range BigDecimal MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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)