Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6688420FD for ; Thu, 5 May 2011 19:45:44 +0000 (UTC) Received: (qmail 34084 invoked by uid 500); 5 May 2011 19:45:42 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 33983 invoked by uid 500); 5 May 2011 19:45:42 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 33857 invoked by uid 99); 5 May 2011 19:45:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 May 2011 19:45:42 +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.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 May 2011 19:45:41 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 5159FC2738 for ; Thu, 5 May 2011 19:45:03 +0000 (UTC) Date: Thu, 5 May 2011 19:45:03 +0000 (UTC) From: "Luc Maisonobe (JIRA)" To: issues@commons.apache.org Message-ID: <1400535301.25740.1304624703330.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1611337119.25353.1304617804221.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (MATH-567) class Dfp toDouble method return -inf whan Dfp value is 0 "zero" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Luc Maisonobe resolved MATH-567. -------------------------------- Resolution: Fixed Fix Version/s: 3.0 Fixed in subversion repository as of r1099938. There were conversions problems in both directions! As you noticed, converting from Dfp to double generated infinities, but creating new Dfp(-0.0) did not preserve the sign. Thanks for the report and the hint for fixing the bug. > class Dfp toDouble method return -inf whan Dfp value is 0 "zero" > ---------------------------------------------------------------- > > Key: MATH-567 > URL: https://issues.apache.org/jira/browse/MATH-567 > Project: Commons Math > Issue Type: Bug > Affects Versions: 2.2 > Reporter: michel > Priority: Minor > Fix For: 3.0 > > > I found a bug in the toDouble() method of the Dfp class. > If the Dfp's value is 0 "zero", the toDouble() method returns a negative infini. > This is because the double value returned has an exposant equal to 0xFFF > and a significand is equal to 0. > In the IEEE754 this is a -inf. > To be equal to zero, the exposant and the significand must be equal to zero. > A simple test case is : > ---------------------------------------------- > import org.apache.commons.math.dfp.DfpField; > public class test { > /** > * @param args > */ > public static void main(String[] args) { > DfpField field = new DfpField(100); > System.out.println("toDouble value of getZero() ="+field.getZero().toDouble()+ > "\ntoDouble value of newDfp(0.0) ="+ > field.newDfp(0.0).toDouble()); > } > } > May be the simplest way to fix it is to test the zero equality at the begin of the toDouble() method, to be able to return the correctly signed zero ? -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira