From owner-freebsd-standards@FreeBSD.ORG Thu Dec 6 09:08:49 2007 Return-Path: Delivered-To: freebsd-standards@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C21B16A417 for ; Thu, 6 Dec 2007 09:08:49 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.freebsd.org (Postfix) with ESMTP id 1F5C413C45B for ; Thu, 6 Dec 2007 09:08:48 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.14.2/8.14.1) with ESMTP id lB698YuB095678; Thu, 6 Dec 2007 04:08:34 -0500 (EST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.14.2/8.14.1/Submit) id lB698XrJ095677; Thu, 6 Dec 2007 04:08:34 -0500 (EST) (envelope-from das@FreeBSD.ORG) Date: Thu, 6 Dec 2007 04:08:33 -0500 From: David Schultz To: Steve Kargl Message-ID: <20071206090833.GA95428@VARK.MIT.EDU> Mail-Followup-To: Steve Kargl , freebsd-standards@FreeBSD.ORG References: <20071012180959.GA36345@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071012180959.GA36345@troutmask.apl.washington.edu> Cc: freebsd-standards@FreeBSD.ORG Subject: Re: [PATCH] hypotl, cabsl, and code removal in cabs X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2007 09:08:49 -0000 I like the approach. One concern, though, is that IEEE 754 requires sqrt to always be correctly rounded, and one might reasonably expect the same from hypot. If we believe that, then the intermediate quantity a*a + b*b needs to be computed exactly; if it is rounded before we take the square root, the double rounding may cause us to round the wrong way. This basically requires computing things with twice as many bits of precision. Arguably, though, your code is correct in the most important ways (avoiding underflow/overflow). Also, umm, I've been busy and unable to pay attention for a while, so forgive me if I'm missing something, but isn't it the case that we don't have a sqrtl(), except for the gcc builtin on some architectures?