public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Faulls <Joseph.Faulls@imgtec.com>
To: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: [PATCH 1/1] newlib: libm: fix complex atan for +/- 1 + 0i
Date: Tue, 26 Sep 2023 11:07:10 +0000	[thread overview]
Message-ID: <LO4P265MB59145B0C9C2889DFD7498E5C80C3A@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM> (raw)

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

Delete check which ensured atan2 was not called with x=0. This is not
necessary as atan2 is defined for x=0 when y != 0. The check incorrectly
resulted in catan returning nan + inf i for when real part is +/- 1 and
imaginary part is 0.

The check could also have implications when called with imaginary number
x + yi where x^2 + y^2 == 1.0. Although this is unlikely due to floating
point precision.
---
newlib/libm/complex/catan.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/newlib/libm/complex/catan.c b/newlib/libm/complex/catan.c
index 77510ec2f..34d75b849 100644
--- a/newlib/libm/complex/catan.c
+++ b/newlib/libm/complex/catan.c
@@ -105,8 +105,6 @@ catan(double complex z)

        x2 = x * x;
        a = 1.0 - x2 - (y * y);
-       if (a == 0.0)
-               goto ovrf;

        t = 0.5 * atan2(2.0 * x, a);
        w = _redupi(t);
--
2.34.1

             reply	other threads:[~2023-09-26 11:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 11:07 Joseph Faulls [this message]
2023-10-09 10:47 ` Joseph Faulls
2023-10-10 19:26   ` Jeff Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=LO4P265MB59145B0C9C2889DFD7498E5C80C3A@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM \
    --to=joseph.faulls@imgtec.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).