From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by sourceware.org (Postfix) with ESMTPS id 0D06F3953C14 for ; Mon, 19 Apr 2021 11:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0D06F3953C14 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MmDVA-1lywnC2PDc-00iCyL for ; Mon, 19 Apr 2021 13:02:58 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id CA8B2A80EC7; Mon, 19 Apr 2021 13:02:57 +0200 (CEST) Date: Mon, 19 Apr 2021 13:02:57 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: hypotl(LDBL_MAX, 0.0L) = inf Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 11:03:10 -0000 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