X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AABB83968C0B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1618830191;
	bh=kaH9yU9fVXFD6dGFPcWdk0cFTaI4MoKtJ/i1/AsMTZM=;
	h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=MCWsX372lEPQC3diwlMMy+nef6bdfQKm/Z3VfELsLGicjsSfwBrexD5chyo6DQ1oU
	 hm1qA2NOkXZnUFPYtty6HUIxFzD9WgGjYM5ZBsYquUHcB3l1BCstjOaf28JQ4sX3BA
	 JuvgAgWkaPe7s4NBeZJ0tVlgkLExMYIgz5GlDVaA=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0D06F3953C14
Date: Mon, 19 Apr 2021 13:02:57 +0200
To: cygwin@cygwin.com
Subject: Re: hypotl(LDBL_MAX, 0.0L) = inf
Message-ID: <YH1jYRu043FXUMm/@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com
References: <vriuo8edqaao.fsf@mail.aol.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <vriuo8edqaao.fsf@mail.aol.com>
X-Provags-ID: V03:K1:pfTfkBDQAvRgBv0TM2t0URDyUuZFG23QO5Kt3qXNqItDFIG6vUY
 5i+PpuxJ3PFsA5bDPX5XFjm2qxoKLrk6XeEmvEppQlYf80K4rSrvvSTtwE9HJcImx4zWMtM
 TUZfo8iZWn6KGeMEQDFOSd1msc3hQobJE+3pxV/+hbQ/cznfbF0Xb25As3YNSs3vz8ydpZh
 ERuDH2JdinZm/D/VRl3IA==
X-UI-Out-Filterresults: notjunk:1;V03:K0:AmMrIkEYo60=:z/P3NNK1CjqQ/tnOMJcxDo
 UMJZzzfHxEagRGrJf6M87azRQetyCbMZ2InWC0w//jwQ18BDcU9IG1+qSn3cM5Dfh6KI3ifrU
 E0C17tjAwRLeNzcfm1rZMVUsv/duCL2+OPHkSHxcoRjgAlwyeB7hxdcPSYijny2hjHcByCo2+
 CPEKiUpxIkgm2ra5vZ3Ucu2NOTocXOZut0faNY+pCKdp4k34VzTlaCEYBlgEIrBzbITRrQdIj
 ZuP8sXFZebG0iqUXs+rDxAl8gRBd6FIEjqF4IhsjrR16ZmZw8iLGhc0d8RyMClupfShDudAXC
 pJgrRdyiLjvQnklnpRGoVJMAV2ResnD2xZne1njuTVkdUTKfZCnfPzfnp+O944SXL+HM3mO30
 I6OBtURFY0107K7bB+pX2k1mRmi4Kox5t4dFrUj7wvUDhJNegaHbLGLdoMFMehli06NEn0ZT5
 2aaPIB2revZdn7p/ZEuvcAUagXluA4ZE7WZGOMeaXOhJ3cDPomrHbiu3yuVNLCPZto0C2GlYa
 JnjliMBb7tqcIn5p4pykmA=
X-Spam-Status: No, score=-100.3 required=5.0 tests=BAYES_00,
 GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS,
 RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL,
 TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces@cygwin.com
Sender: "Cygwin" <cygwin-bounces@cygwin.com>

On Apr 17 10:02, airplanemath via Cygwin wrote:
> Given that hypot(DBL_MAX, 0.0) = DBL_MAX and hypotf(FLT_MAX, 0.0f) =
> FLT_MAX, I suspect this is a problem in hypotl.  Am I missing something?

No.  This is a bug in newlib's hypotl.  Newlib mainly targest embedded
systems and as such wasn't very much interested in long double arithmetic
for a long time.

In contrast to hypot and hypotf, it's not implemented as exact function,
but just as the outside idea sqrtl (x^2 + y^2).  With LDBL_MAX ^ 2 ==
inf as input, sqrtl returns inf.  So what we get here is an intermediate
overflow, that wouldn't occur if the hypotl function would be implemented
in detail.

The problem is, somebody would have to do it.  That is, implementing
a hypotl which works for all supported CPU types.  There are quite a few
long double variations in the wild, unfortunately...

Having said that, there's an easier way out for Cygwin: We just use
the hypotl function from Mingw-w64 for Cygwin as well.

I pushed this patch and uploaded new developer snapshots to
https://cygwin/snapshots/

Please give it a try.


Thanks,
Corinna
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
