Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240812090022.GA3766212@port70.net>
Date: Mon, 12 Aug 2024 11:00:22 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: Damian McGuckin <damianm@....com.au>
Cc: MUSL <musl@...ts.openwall.com>
Subject: Re: catan(z)

* Damian McGuckin <damianm@....com.au> [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.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.