From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 906F43858C98 for ; Fri, 5 Jan 2024 17:34:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 906F43858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 906F43858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704476098; cv=none; b=CSPTYk7nEO1IvIuEo7kIVrcgjEKmI/whtungMeb5N4frrofa+g9E3P3jgnnMalR0TQC9xqd9bjg94lncel3BUE5DRTc0P5v5KNjf8H9hBoZrOE0T9VtlQ6kplsZ0oXPq1R5YlO0B9bVhZSMxlEYoNjsx7jRNVBWje33JFmXlAXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704476098; c=relaxed/simple; bh=TkM/yyk/xNf6du3poAlBGw8K1nUC3k8a1csPLonaigo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=w+rhcBMUdsSg7W89Rt18wpyZBsNSw4bufUa854k3X2ecvdpc6+X3FZVAKHXHSTY5r6EK5odgX+aKZxgV5FgYqeD15BKl1udHhKiESYxbEKFKsacKR9h0CqkHq6Ywu5MkmrqOjRz2QAFXG2/f1ydC/i4cgTp7h2U/18lCMUSUEQ0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40d5d8a6730so16228355e9.1 for ; Fri, 05 Jan 2024 09:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704476095; x=1705080895; darn=sourceware.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=NZ+SyaTM5LYzckYYHnuNbup/5UrIa3R7P0vdN4gI+hs=; b=nnl9kD3n0jl0vUhHwezbSxdNaSUUyx7yOhti9HmGcS6p9aKeQ6kqLTx5uu2/coVVFF 8cZhe9bSMTiTg8U2/Rnn4WYsk9GYOyTj2cziCJdOUYdmMNw3fTgPOywMd9eGMUIZDbhE 3fosOWA2wdyBCD96L8GIZR6xLfbAH/4Snw8IXE0efmLak27XBPESLHXGmtnRlhIlRRh3 8/ThMuEuEBVvopna2R6F8PvM+Xwq/EYgihjMQu+cxN3KUQq85Ml9DqxMJ3Lcza8bt/V8 x+DVf6d3Jvn4Kxk5Y+uj6orKdAlFghqgLvEgCO3B2JuXhG6SZ5JC9ler4ASxfqV54xpi YFig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704476095; x=1705080895; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NZ+SyaTM5LYzckYYHnuNbup/5UrIa3R7P0vdN4gI+hs=; b=q/R5Qf6zXWSmedTAKt6v+Gh8x+kLd7Yst8VoAvCuUEhcVeioLyNqphLSQlEC+PIhen qvLCeDPqZL5msjJOhdXf0wzy5qwnhY+KoBCouHj5iEDu6TLrx++kF+mmSLuwsTB+irq3 wReIZeezPh2J3+hRNHVcpHbCSy1nmnr///050CfBa7w6rxwp/IgV6aW/MpSfEe5kp8Gh AHAWkm2y5GfjJf27Tw0NH49d0UddNBAWBtxgbhPIlKdQXAjpIhOKR+30h1YZ5qkR5W+y SOZtI5O0xdeSS7Nmp0keHXivgwX/vGbq7ynnyPevlZQwt44IoJ4ovN23kiCB5VVEjbjq /5Sg== X-Gm-Message-State: AOJu0Ywc/qkp69cTPCw28QTab+6mSXj1yyhIkTHP5piGCyffRexc4OzV uE9y+2l89Yhp0S423eUYkZIiNaYwQsYQtHuDR3tvvS2nrw== X-Google-Smtp-Source: AGHT+IE/IdiEaEySG+Z0KxkhJ2Rg3D0KYCFjZ0CpE8SnaIFFS8H4CAri2zjLEwmnSrBl1edvIEawEbwZf9ufYHES578= X-Received: by 2002:a05:600c:1908:b0:40d:5c56:a63 with SMTP id j8-20020a05600c190800b0040d5c560a63mr1369242wmq.79.1704476094756; Fri, 05 Jan 2024 09:34:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: C Howland Date: Fri, 5 Jan 2024 12:34:43 -0500 Message-ID: Subject: Re: Fw: issue with tgamma To: newlib@sourceware.org Content-Type: multipart/alternative; boundary="00000000000027fcf8060e364457" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,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: --00000000000027fcf8060e364457 Content-Type: text/plain; charset="UTF-8" > *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 --00000000000027fcf8060e364457--