Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 28 May 2024 21:38:14 -0400
From: Rich Felker <dalias@...c.org>
To: Nikolaos Chatzikonstantinou <nchatz314@...il.com>
Cc: Markus Wichmann <nullplan@....net>, musl@...ts.openwall.com
Subject: Re: Re: Implementing csqrtl()

On Tue, Jul 05, 2022 at 04:14:13PM +0000, Nikolaos Chatzikonstantinou wrote:
> On Tue, Jul 5, 2022 at 3:35 PM Markus Wichmann <nullplan@....net> wrote:
> >
> > On Tue, Jul 05, 2022 at 02:28:32PM +0000, Nikolaos Chatzikonstantinou wrote:
> > > On Tue, Jul 5, 2022 at 9:37 AM Szabolcs Nagy <nsz@...t70.net> wrote:
> > > >
> > > > * Nikolaos Chatzikonstantinou <nchatz314@...il.com> [2022-07-04 11:09:44 +0000]:
> > > >
> > > > > +  if ((isinf(x) || isinf(y)) && (isnan(r) || isinf(r))) {
> > > >
> > > > why do you need the && ?
> > > > can r be other than inf or nan?
> > >
> > > It's the case that x^2 + y^2 is inf for x,y finite.
> > >
> >
> > Yeah, but if x or y is infinite then so is r. So the entire part in
> > front of the && is redundant, because it is contained in the second
> > part.
> >
> > Unless I completely misunderstood how IEEE infinity works...
> 
> Yes you are right, it should be if(isinf(x) || isinf(y)).

I don't think this is correct. It's possible for r (which actually
holds a value I would call r², perhaps r2 as var name?) to be infinite
even when x and y are finite. This sounds problematic. Don't you need
to work with actual r, guaranteed to be finite when x and y are, which
you could obtain from hypotl?

Rich

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.