From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 87A3420092 for ; Fri, 16 Aug 2024 03:47:21 +0200 (CEST) Received: (qmail 23910 invoked by uid 550); 16 Aug 2024 01:47:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 23872 invoked from network); 16 Aug 2024 01:47:15 -0000 Date: Fri, 16 Aug 2024 11:47:03 +1000 (AEST) From: Damian McGuckin To: musl@lists.openwall.com cc: Morten Welinder In-Reply-To: <20240815134415.GO10433@brightrain.aerifal.cx> Message-ID: References: <21ca5c9-b1e-71b5-87b-a37f81f691ab@esi.com.au> <20240811200812.GZ3766212@port70.net> <7e9463-98a3-4b2-c10-e3fbf79a6b8@esi.com.au> <5918d2a7-7b3-932b-2b4-b24390832244@esi.com.au> <20240815134415.GO10433@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: Re: [musl] catan(z) On Thu, 15 Aug 2024, Rich Felker wrote: > On Thu, Aug 15, 2024 at 09:18:19AM -0400, Morten Welinder wrote: >> atan2 definitely isn't supposed to always output rational numbers on >> rational input. >> >> atan2(+0,-1) is Pi. >> atan2(-0,-1) is -Pi >> atan2(1,1) is Pi/4 -- clearly not a rational number. >> >> These aren't exactly rational results (unless you mean their >> floating-point approximations). > > The way I read it, the claim was not that the exact mathematical value > of atan2 for some argument is rational, but that the floating point > number returned by the C function is necessarily rational (because all > floating point numbers are diadic rationals) and thus never actually > equal to ?pi. This means you don't have any issue with whatever > happens exactly at the endpoints. Precisely. Sorry if I was unclear Morten. Actually, I think we need to ensure we use a value of Pi above which is rounded towards zero (rather than one rounded to nearest tied to even) so that it never lies outside the exact range of [-PI,+PI] where PI in this case is an irrational number that we cannot represent with an IEEE 754 floating point number. If we can enhance catan(z) to explicitly handle the special cases of Annex G of the C standard, some of this discussion becomes a lot simpler. But at the time he wrote this routine, Moshier did not have the luxury of a standard to consult. - Damian