mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Damian McGuckin <damianm@esi.com.au>
To: MUSL <musl@lists.openwall.com>
Subject: [musl] Special cases in csinh and ctanh
Date: Wed, 7 Aug 2024 00:02:59 +1000 (AEST)	[thread overview]
Message-ID: <fb3a7daf-f478-1cb2-cc4-757d8b40bbfa@esi.com.au> (raw)


Some special cases in ctanh.c are listed below:

 	/*
 	 * ctanh(+-0 + i NAN) = +-0 + i NaN
 	 * ctanh(+-0 +- i Inf) = +-0 + i NaN
 	 * ctanh(x + i NAN) = NaN + i NaN
 	 * ctanh(x +- i Inf) = NaN + i NaN
 	 */
 	if (!isfinite(y))
 		return CMPLX(x ? y - y : x, y - y);

What I thought are the same special cases in csinh.c are listed below:
They are processed differently in csinh than in ctanh.

 	/*
 	 * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
 	 * The sign of 0 in the result is unspecified.  Choice = normally
 	 * the same as dNaN.  Raise the invalid floating-point exception.
 	 *
 	 * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
 	 * The sign of 0 in the result is unspecified.  Choice = normally
 	 * the same as d(NaN).
 	 */
 	if ((ix | lx) == 0 && iy >= 0x7ff00000)
 		return CMPLX(copysign(0, x * (y - y)), y - y);

 	/*
 	 * sinh(x +- I Inf) = dNaN + I dNaN.
 	 * Raise the invalid floating-point exception for finite nonzero x.
 	 *
 	 * sinh(x + I NaN) = d(NaN) + I d(NaN).
 	 * Optionally raises the invalid floating-point exception for finite
 	 * nonzero x.  Choice = don't raise (except for signaling NaNs).
 	 */
 	if (ix < 0x7ff00000 && iy >= 0x7ff00000)
 		return CMPLX(y - y, x * (y - y));

I realise that 'y - y' creates a NaN when y is either an Infinity or NaN.
Won't that also raise an INVALID exception?

What does

 	x * (y - y)

achieve that y - y does not (in the above)

Thanks - Damian

             reply	other threads:[~2024-08-06 14:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 14:02 Damian McGuckin [this message]
2024-08-06 15:46 ` Markus Wichmann
2024-08-07  0:51   ` Damian McGuckin

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=fb3a7daf-f478-1cb2-cc4-757d8b40bbfa@esi.com.au \
    --to=damianm@esi.com.au \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).