mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Special cases in csinh and ctanh
@ 2024-08-06 14:02 Damian McGuckin
  2024-08-06 15:46 ` Markus Wichmann
  0 siblings, 1 reply; 3+ messages in thread
From: Damian McGuckin @ 2024-08-06 14:02 UTC (permalink / raw)
  To: MUSL


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-07  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-06 14:02 [musl] Special cases in csinh and ctanh Damian McGuckin
2024-08-06 15:46 ` Markus Wichmann
2024-08-07  0:51   ` Damian McGuckin

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).