From owner-freebsd-numerics@FreeBSD.ORG Fri Sep 12 22:17:24 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6BCADF6 for ; Fri, 12 Sep 2014 22:17:24 +0000 (UTC) Received: from mail-yh0-x236.google.com (mail-yh0-x236.google.com [IPv6:2607:f8b0:4002:c01::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2840F175 for ; Fri, 12 Sep 2014 22:17:24 +0000 (UTC) Received: by mail-yh0-f54.google.com with SMTP id z6so700746yhz.41 for ; Fri, 12 Sep 2014 15:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=XtaJ6NrXjM9DqybcZTc9CuSaAXjCWQNOQtkmcvHKyz0=; b=El2prp6mhqVruz5t6o7dLGJByix25cU92n0MJ4fnt7WkwlFNI0DutQ6rFCqp5DK2nx Cg3a8cuozXaPshA13q80GVDAiIgWfKrQhhJexog83eyGiDgEIon3lQ/mHbIPSYi6wzD6 RpJ1L4cUrYjuv9Ify1Jwh/+WBvA7KFEYP8Ke3OzKYzjqXM1CxIYb5uwudZBHdpSnyXtT 3mwvij/PQ9IrhF9t6YQsRQcHX/mdaAZVb7B08ZIPwKg2W7Tq152fOtWvLBSPqtuR9xAZ RIlmqbBShsV3dlc+Sx0yLUnFDx/XN39R+Li57dB40qJU4mUU2PC5Ea9iskhTLxCcBJhb mbEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=XtaJ6NrXjM9DqybcZTc9CuSaAXjCWQNOQtkmcvHKyz0=; b=l0fmagT9NT2GQ90EP2IWALbtqIEGcvKTWNKtccs08QspFSi+mZ17WEAQoYYA5rynmA D9mC890NHI4xEtCQrUfvhDR9MBfHmCep2YMXQUMLMZw27VWRmHTaQlTdq7stHfyRrqty CHLlUm53K4lFNsC9O/jyPcag8bO5FKSOM6ApHLIxmgy412kVEHiDGng1KXcPzoZOiL5q iscl6wWFQKHDMokYJjWU4O/WN2MnpGkuMPV63pc3W2f8jxN/VjWkVS38V2/wqghPr8e0 tKLsyKSUG81cXv4Mwhgzj0W6vl5nrJrXBJmhhXH9NBrSaBiWN1hrlmm8vH+8/4BPSRjZ vT2g== X-Gm-Message-State: ALoCoQkvTajk8K0g4K+ybFa7IzFYcYA2gNcIqS/aLr94lw20Dw5rCka6c8ggt31JwNME6T3pH0DC X-Received: by 10.236.229.138 with SMTP id h10mr3735867yhq.122.1410560243094; Fri, 12 Sep 2014 15:17:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.170.147.69 with HTTP; Fri, 12 Sep 2014 15:17:02 -0700 (PDT) In-Reply-To: <20140912220544.GA96714@troutmask.apl.washington.edu> References: <20140912220544.GA96714@troutmask.apl.washington.edu> From: enh Date: Fri, 12 Sep 2014 15:17:02 -0700 Message-ID: Subject: Re: lgamma_r and lgammaf_r return the wrong sign for -0.f To: Steve Kargl Content-Type: text/plain; charset=UTF-8 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 22:17:24 -0000 On Fri, Sep 12, 2014 at 3:05 PM, Steve Kargl wrote: > On Fri, Sep 12, 2014 at 02:15:37PM -0700, enh via freebsd-numerics wrote: >> if I pass -0.f to lgammaf_r, the sign returned in *signgamp is 1. this >> is incorrect --- it should be -1. >> >> both lgamma_r and lgammaf_r are affected, but the other special cases >> in those functions look fine to me. >> >> this is fixed in OpenBSD and glibc, but FreeBSD and NetBSD both have >> the same bug. > > Are you sure FreeBSD has a bug? From n1256.pdf (committee draft of C99) note that i'm reporting bugs in lgamma_r and lgammaf_r. lgamma and lgammaf don't have an out argument for the sign. > 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-pointr > 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. > > 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. >> btw, it looks like you're missing coshl/sinhl/tanhl for ld128 now? >> (they've been removed from imprecise.c without having ld128 >> implementations added afaics.) > > The ld80 and ld128 versions are in the same file. > > troutmask:fvwm:kargl[226] grep LDBL /usr/src/lib/msun/src/e_coshl.c > #if LDBL_MAX_EXP != 0x4000 > #define BIAS (LDBL_MAX_EXP - 1) > #if LDBL_MANT_DIG == 64 > #elif LDBL_MANT_DIG == 113 > #endif /* LDBL_MANT_DIG == 64 */ > GET_LDBL_EXPSIGN(ix,x); > if (ix #if LDBL_MANT_DIG == 64 > #elif LDBL_MANT_DIG == 113 > > see also e_sinhl.c and s_tanhl.c. d'oh. yes, i need to import those files! --elliott