Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C67AC200B87 for ; Mon, 19 Sep 2016 19:28:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C55EB160AE1; Mon, 19 Sep 2016 17:28:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 19789160ACC for ; Mon, 19 Sep 2016 19:28:22 +0200 (CEST) Received: (qmail 62951 invoked by uid 500); 19 Sep 2016 17:28:22 -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 62795 invoked by uid 99); 19 Sep 2016 17:28:22 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Sep 2016 17:28:22 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 093872C0D5A for ; Mon, 19 Sep 2016 17:28:22 +0000 (UTC) Date: Mon, 19 Sep 2016 17:28:22 +0000 (UTC) From: "Brian McCormick (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MATH-1386) EPSILON value in org.apache.commons.math.util.MathUtils seems like half of what it should be MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 19 Sep 2016 17:28:24 -0000 [ https://issues.apache.org/jira/browse/MATH-1386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15504074#comment-15504074 ] Brian McCormick commented on MATH-1386: --------------------------------------- double epsilon = Double.longBitsToDouble(Double.doubleToLongBits(1) + 1) - 1; Brian McCormick MCB Systems Inc. Phone: 918-749-5453 email: Brian.McCormick@mcbsystems.us > EPSILON value in org.apache.commons.math.util.MathUtils seems like half of what it should be > --------------------------------------------------------------------------------------------- > > Key: MATH-1386 > URL: https://issues.apache.org/jira/browse/MATH-1386 > Project: Commons Math > Issue Type: Bug > Environment: win 7 > Reporter: Brian S. McCormick > Original Estimate: 1h > Remaining Estimate: 1h > > I've always used 1.1920929E-7 for dealing with float epsilon values. When dealing with double I've always used 2.220446049250313E-16 for epsilon. > You have it defined in org.apache.commons.math.util.MathUtils as 1.1102230246251565E-16 which is half what I think it should be. > I come up with these numbers using the following: > float fEps = Float.intBitsToFloat(Float.floatToIntBits(1f) + 1) - 1; > double dEps = Double.longBitsToDouble(Double.doubleToLongBits(1) + 1) - 1; > Am I correct? I don't really know. I do know that float epsilon in every legacy C/C++ compiler etc I have ever used is defined as about 1e-7 and this is the value using the formula for fEps above. When I started doing comps using doubles instead of floats I started using the formula for dEps above which looks to me like the equivalent for double numbers. -- This message was sent by Atlassian JIRA (v6.3.4#6332)