From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sourceware.org (Postfix) with ESMTPS id E9B1D3858D35 for ; Mon, 8 Jan 2024 14:45:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9B1D3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=inria.fr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E9B1D3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.134.164.104 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704725123; cv=none; b=xLBCOzh90iX8RiZ35CJfwGoYQyCL7X3Tw9aw3CYius51rsVj9gtZqbM/CVa6Q0aq4dh89eSt2Vu499zOBhysVLgjqO39lBKDgKBac/Lbfdt7ImfS57Qzga1Tnci8J6YOzHfEWHNnyt6N4KWH0DjSS7Fl570Z2XYOVHQxk5vZWSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704725123; c=relaxed/simple; bh=pRCFoW6yxNLdqnQMuzgJE29QtbcswkFXlMZs5loSEOI=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=EkcwTF5OuQQ/bGBugdcFvyKUE7QJEzyQTlapWs8wzyhj3qNvgeM1ArUjSBf9Tk4DsBS7BroNxYJ64uAgyumuVdZuV8UZvT0oD69g/nPqzDV0OOeRVpkPkemNTOr564Dny2hiePyeXz10tq1141IPbkuFuN4uSYn0sRDpfoDRR1A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:message-id:from:to:cc:in-reply-to:subject: references; bh=okKlfIMYt1jqJpyyS0ePgYEDawDUrZ9nVBs7adGo3Ns=; b=LbGzQ3YjHG5UBBJpEUXuzAP5+5RyHB4B7qJR9Q+1qsaNd9MzPOvsyqVz 5x0+yIMXqoebVxuPeHpPzoq6WwYHpD1BcK8crqiOaiDmXZdp8Ho1a6W+T AVwSAHIFgD7AW0rZgIhcZxuPcmJczwl0mU8tW0hpQ7/ZxK2WyIHw8Js68 w=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Paul.Zimmermann@inria.fr; spf=None smtp.helo=postmaster@biscotte Received-SPF: SoftFail (mail3-relais-sop.national.inria.fr: domain of Paul.Zimmermann@inria.fr is inclined to not designate 152.81.4.127 as permitted sender) identity=mailfrom; client-ip=152.81.4.127; receiver=mail3-relais-sop.national.inria.fr; envelope-from="Paul.Zimmermann@inria.fr"; x-sender="Paul.Zimmermann@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 include:mailout.safebrands.com a:basic-mail.safebrands.com a:basic-mail02.safebrands.com ip4:128.93.142.0/24 ip4:192.134.164.0/24 ip4:128.93.162.160 ip4:89.107.174.7 mx ~all" Received-SPF: None (mail3-relais-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@biscotte) identity=helo; client-ip=152.81.4.127; receiver=mail3-relais-sop.national.inria.fr; envelope-from="Paul.Zimmermann@inria.fr"; x-sender="postmaster@biscotte"; x-conformance=spf_only X-IronPort-AV: E=Sophos;i="6.04,341,1695679200"; d="scan'208";a="76145063" Received: from biscotte.loria.fr (HELO biscotte) ([152.81.4.127]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 15:45:20 +0100 Date: Mon, 08 Jan 2024 15:45:19 +0100 Message-Id: From: Paul Zimmermann To: C Howland Cc: newlib@sourceware.org In-Reply-To: (message from C Howland on Fri, 5 Jan 2024 12:34:43 -0500) Subject: Re: Fw: issue with tgamma References: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Craig, you are perfectly right. I'll have to adapt our testing framework. However, does Newlib yield a domain or range error? I cannot test, since I have to provide a fake errno to be able to compile my program with Newlib's libm.a. Paul > From: C Howland > Date: Fri, 5 Jan 2024 12:34:43 -0500 > > > [1:text/plain Show] > > > [2:text/html Hide Save:noname (2kB)] > > From: Paul Zimmermann > Sent: Friday, January 5, 2024 5:49 AM > To: newlib@sourceware.org > Subject: issue with tgamma > > Hi, > > I discovered the following issue with tgamma: for > x=-0x1.13a5ccd87c9bbp+1008 > it yields +Inf instead of NaN: > > Checking tgamma with newlib-4.4.0.20231231 > tgamma 0 -1 -0x1.13a5ccd87c9bbp+1008 [-nan] [inf] inf inf > libm gives inf > mpfr gives -nan > > This issue was present in earlier versions of Newlib, but we only found > it > recently since we improved our testing framework. > > Paul > > This strictly is OK, as the standards allow either a range or domain > error for negative integers, and domain errors may return an > implementation-defined value. It most likely has been this way since the > 1993 date in the source file, which includes > * 5. Special Cases > * lgamma(2+s) ~ s*(1-Euler) for tiny s > * lgamma(1)=lgamma(2)=0 > * lgamma(x) ~ -log(x) for tiny x > * lgamma(0) = lgamma(inf) = inf > * lgamma(-integer) = +-inf > (The tgamma function ends up using the lgamma function.) > POSIX does have an implied preference of sorts for the NaN return, so > changing it could possibly be considered a small improvement even if not > necessary--although it is strange that they define the result for argument 0 > differently, calling for INF there, seems inconsistent. > (It's somewhat interesting that the MPFR return value you show is -NaN. > I suppose they chose that to help reflect it being due to a negative > argument.) > Craig