Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 29573 invoked from network); 23 Nov 2006 08:26:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Nov 2006 08:26:33 -0000 Received: (qmail 75404 invoked by uid 500); 23 Nov 2006 08:26:38 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 75370 invoked by uid 500); 23 Nov 2006 08:26:38 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 75272 invoked by uid 99); 23 Nov 2006 08:26:38 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Nov 2006 00:26:38 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Nov 2006 00:26:27 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 037B77141E4 for ; Thu, 23 Nov 2006 00:26:07 -0800 (PST) Message-ID: <26612324.1164270367011.JavaMail.jira@brutus> Date: Thu, 23 Nov 2006 00:26:07 -0800 (PST) From: "Leo Li (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-329) Endless loop when using Double.parseDouble(String) with certain types of value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/HARMONY-329?page=comments#action_12452169 ] Leo Li commented on HARMONY-329: -------------------------------- It is a fault of the algorithm in the math lab used by harmony. In the file trunk/modules/luni/src/main/native/luni/shared/dblparse.c there is a comment of function doubleAlgorithm: /* The algorithm for the function doubleAlgorithm() below can be found * in: * * "How to Read Floating-Point Numbers Accurately", William D. * Clinger, Proceedings of the ACM SIGPLAN '90 Conference on * Programming Language Design and Implementation, June 20-22, * 1990, pp. 92-101. * * There is a possibility that the function will end up in an endless * loop if the given approximating floating-point number (a very small * floating-point whose value is very close to zero) straddles between * two approximating integer values. We modified the algorithm slightly * to detect the case where it oscillates back and forth between * incrementing and decrementing the floating-point approximation. It * is currently set such that if the oscillation occurs more than twice * then return the original approximation. */ It seems that it will fail in endless loop in the testcase. Any suggestion? > Endless loop when using Double.parseDouble(String) with certain types of value > ------------------------------------------------------------------------------ > > Key: HARMONY-329 > URL: http://issues.apache.org/jira/browse/HARMONY-329 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Sian January > > Calling Double.parseDouble(..) with certain Strings (e.g. Double.parseDouble("-1.233999999999999965116738099630936817275852021384209929081813042837802886790127428328465579708849276001782791006814286802871737087810957327493372866733334925806221045495205250590286471187577636646208155890426896101636282423463443661040209738873506655844025580428394216030152374941053494694642722606658935546875E-112");) causes an endless loop. > Although this is not necessarily a case you would see in regular programming it happens when you do something like new BigDecimal(-1.234E-112).doubleValue(), which was the cause of the endless loop mentioned in HARMONY-319. > The loop occurs in the native method "doubleAlgorithm (JNIEnv * env, U_64 * f, IDATA length, jint e, jdouble z)" in native-src/shared/math/dblparse.c. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira