From owner-freebsd-numerics@FreeBSD.ORG Fri Sep 12 23:37:50 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ADB3D33A for ; Fri, 12 Sep 2014 23:37:50 +0000 (UTC) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask.apl.washington.edu", Issuer "troutmask.apl.washington.edu" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 84AC6B16 for ; Fri, 12 Sep 2014 23:37:50 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id s8CNbnpA098025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Sep 2014 16:37:49 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id s8CNbnuL098024; Fri, 12 Sep 2014 16:37:49 -0700 (PDT) (envelope-from sgk) Date: Fri, 12 Sep 2014 16:37:49 -0700 From: Steve Kargl To: enh Subject: Re: lgamma_r and lgammaf_r return the wrong sign for -0.f Message-ID: <20140912233749.GA97910@troutmask.apl.washington.edu> References: <20140912220544.GA96714@troutmask.apl.washington.edu> <20140912224112.GA97578@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2014 23:37:50 -0000 On Fri, Sep 12, 2014 at 03:51:52PM -0700, enh wrote: > On Fri, Sep 12, 2014 at 3:41 PM, Steve Kargl > wrote: > > On Fri, Sep 12, 2014 at 03:17:02PM -0700, enh via freebsd-numerics wrote: > >> On Fri, Sep 12, 2014 at 3:05 PM, Steve Kargl > >> > F.9.5.3 The lgamma functions > >> > -- lgamma(1) returns +0. > >> > -- lgamma(2) returns +0. > >> > -- lgamma(x) returns +inf and raises the ``divide-by-zero'' floating-point > >> > exception for x a negative integer or zero. > >> > -- lgamma(-inf) returns +inf. > >> > -- lgamma(+inf) returns +inf. > >> > > >> > See the 3rd bullet. -0 is 0 and -0 is a negative integer. > > > > Of course, neither POSIX nor ISO C specify lgamma_r() only lgamma. > > I just spent too much time on the 'divide-by-zero' bug, and > > conflated that with signgam. > > i think the reporter's feeling was that *signgamp should be -1 because > as x approaches 0 from the negative side, Gamma(x) approaches > -Infinity. (though i suspect they noticed this when porting code from > glibc.) Mathematically, gamma(x) -> +inf as x -> 0 for x > 0 and gamma(x) -> -inf as x -> 0 for x < 0. Assuming that a processor supports a signed zero, it happens that x = +-0 is the only integral floating point value that allows one to infer a sign for signgam. All other negative integral values, of course, do not have this possible, so signgam is arbitrarily assigned 1. > >> > POSIX appears to defer to ISO C. n1570.pdf (committe draft for C11) > >> > has (almost?) identical text. > >> > > >> >> patch below (whitespace mangled courtesy of gmail). i'd prefer to wait > >> >> for this to be fixed in FreeBSD and pull down the fix rather than just > >> >> fix it locally. > >> > > >> > I have a bigger patch coming with ld80 and ld128 version of lgammal > >> > and lgammal_r. > >> > >> sorry, i haven't even looked at the *l variants. > > > > I only just finished writing the *l variants. It took me > > a long time to unwind the comments in e_lgamma_r.c, > > so that I could write the long double versions. > > is there a freebsd-numerics-commits or equivalent i could subscribe to? No. I tend to post my patches here. Then Bruce Evans and I tend to go off on private email threads with code reviews. A few months later I get around to address issues raised by Bruce, and submit a new patch. This cycle goes on for a year or so, and then I finally commit my patches. There are also a few developers (most MIPS/ARMS) that have been fixing fenv.h issues. They commit their patches without posting to freebsd-numerics. I'll note that my lgamma.diff file is clocking in at 1400 LOC. mailman may eat my post. In the end, it is probably prudent to simply look periodically at FreeBSD's src/lib/msun through the svnweb interface. -- Steve