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 CDEA01044A for ; Thu, 5 Dec 2013 21:34:36 +0000 (UTC) Received: (qmail 73106 invoked by uid 500); 5 Dec 2013 21:34:36 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 73017 invoked by uid 500); 5 Dec 2013 21:34:36 -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 73008 invoked by uid 99); 5 Dec 2013 21:34:36 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Dec 2013 21:34:36 +0000 Date: Thu, 5 Dec 2013 21:34:36 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MATH-1068) KendallsCorrelation suffers from integer overflow for large arrays. 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-1068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13840595#comment-13840595 ] Thomas Neidhart commented on MATH-1068: --------------------------------------- Can you please attach a test case for this? Thanks > KendallsCorrelation suffers from integer overflow for large arrays. > ------------------------------------------------------------------- > > Key: MATH-1068 > URL: https://issues.apache.org/jira/browse/MATH-1068 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.3 > Reporter: Gal Lalouche > Priority: Minor > Labels: newbie > Fix For: 3.3 > > Original Estimate: 1m > Remaining Estimate: 1m > > For large array size (say, over 5,000), numPairs > 10 million. > in line 258, (numPairs - tiedXPairs) * (numPairs - tiedYPairs) possibly > 100 billion, which will cause an integer overflow, resulting in a negative number, which will result in the end result in a NaN since the square-root of that number is calculated. > This can easily be solved by changing line 163 to > final long numPairs = ((long)n) * (n - 1) / 2; // to avoid overflow -- This message was sent by Atlassian JIRA (v6.1#6144)