[Cfp-interest 1849] Re: hypot(SNAN,+0)

Jim Thomas jaswthomas at sbcglobal.net
Fri Nov 20 17:07:04 PST 2020



> On Oct 28, 2020, at 9:16 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> C23 F.10.4.4 has
>  hypot(x, ±0) is equivalent to fabs(x).
> 
> Is that true for x being a Signaling NaN?

No. We could say

	hypot(x, ±0) is equivalent to fabs(x), for all x not a signaling NaN.

But, either way, this seems to require hypot(x, ±0) to be a sign bit operation, which we don’t want for multiple reasons (treatment of NaNs,  preferred quantum exponent, canonicalization).

754 says

hypot(x, y) is even in both operands.

...

For the hypot operation, hypot(±0, ±0) is +0, hypot(±∞, qNaN) is +∞, and hypot(qNaN, ±∞) is +∞. 

Draft C23 F.10.4.4 says 

— hypot(x, y), hypot(y, x), and hypot(x, −y) are equivalent. 
— hypot(x, ±0) is equivalent to fabs(x). 
— hypot(±∞, y) returns +∞, even if y is a NaN.

The equivalence to fabs guarantees the 754 requirement about zeros and also requires correct rounding for y (or x) = ±0. We could replace the bullet about fabs with the two bullets

— hypot(±0, ±0) is +0.
— hypot(x, ±0) is numerically equivalent to fabs(x). 

- Jim Thomas

> 
> fabs(SNAN) raises no floating-point exceptions.
> 
> 
> 
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com      Testing, numerics, programming
> +1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
> Sample C99+FPCE tests: http://www.tybor.com
> Savers sleep well, investors eat well, spenders work forever.
> 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20201120/bbadc76e/attachment.htm>


More information about the Cfp-interest mailing list