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 F2574226BA for ; Mon, 12 Aug 2024 11:00:36 +0200 (CEST) Received: (qmail 28262 invoked by uid 550); 12 Aug 2024 09:00:32 -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 28221 invoked from network); 12 Aug 2024 09:00:32 -0000 Date: Mon, 12 Aug 2024 11:00:22 +0200 From: Szabolcs Nagy To: Damian McGuckin Cc: MUSL Message-ID: <20240812090022.GA3766212@port70.net> Mail-Followup-To: Damian McGuckin , MUSL 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5918d2a7-7b3-932b-2b4-b24390832244@esi.com.au> Subject: Re: [musl] catan(z) * Damian McGuckin [2024-08-12 13:56:18 +1000]: > On Mon, 12 Aug 2024, Damian McGuckin wrote: > > > There is some argument that if you handle the special cases at infinity > > separately (which I think MUSL should do but I do not have time at the > > moment), then one can assume that because pi/2 is irrational, then one > > should never have to deal with the end points in the chunk of code where > > those two lines of code seen above should appear. I will have a chat > > sometime with the guy who wrote that logic in a WG14 paper when I get a > > really clear head and can line him up. > > Consider > > atan2(y, x) > > For any finite y and finite non-zero x floating point number arguments, i.e. > rational numbers, the result of atan2(y, x) must be rational and so is never > +/- pi (which is irrational and only occurs when the ration y/x is a > mathematical infinity, not an overflowing infinity). So, we can ignore the > endpoints as long as our special case handling takes care of the case of > zero x. > > I think that is correct .... or is my brain still not working properly after > too many late nights watching the Olympics. well atan2 cannot return exact +-pi, but one would still expect the right sign for the quadrant (y=+-0, x<0 case or finite y, x=-inf case) and then _redupi uses (int)(t/pi+-0.5) where that /pi is not exact the same way the +-pi returned from atan2 was not exact. i.e currently in the atan2==+-pi case the sign gets flipped by _redupi (even though double pi < exact pi so no need to reduce) i doubt the sign flip is needed, but even if that's the right result there are better ways to handle that case.