From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 22:58:22 2012 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31B1E106564A for ; Sun, 12 Aug 2012 22:58:22 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by mx1.freebsd.org (Postfix) with ESMTP id BE8F98FC14 for ; Sun, 12 Aug 2012 22:58:21 +0000 (UTC) Received: from server.rulingia.com (c220-239-249-137.belrs5.nsw.optusnet.com.au [220.239.249.137]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CMwLUw075527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 08:58:21 +1000 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CMwFMx020935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 08:58:15 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CMwF1S020934 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 08:58:15 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 08:58:15 +1000 Resent-Message-ID: <20120812225815.GM20453@server.rulingia.com> Resent-To: freebsd-numerics@freebsd.org Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q6JNiUOk022480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Jul 2012 09:44:31 +1000 (EST) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q6JNiSej084612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 20 Jul 2012 09:44:30 +1000 (EST) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id q6JNiQIL006309; Thu, 19 Jul 2012 16:44:26 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id q6JNiPHO006308; Thu, 19 Jul 2012 16:44:25 -0700 (PDT) (envelope-from sgk) From: Steve Kargl Mail-Followup-To: freebsd-numerics@freebsd.org To: Peter Jeremy Message-ID: <20120719234425.GA6280@troutmask.apl.washington.edu> References: <5004A5C7.1040405@missouri.edu> <5004DEA9.1050001@missouri.edu> <20120717040118.GA86840@troutmask.apl.washington.edu> <20120717042125.GF66913@server.rulingia.com> <20120717043848.GB87001@troutmask.apl.washington.edu> <20120717225328.GA86902@server.rulingia.com> <20120717232740.GA95026@troutmask.apl.washington.edu> <20120718001337.GA87817@server.rulingia.com> <20120718123627.D1575@besplex.bde.org> <20120719213944.GA21199@server.rulingia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120719213944.GA21199@server.rulingia.com> User-Agent: Mutt/1.4.2.3i Cc: Diane Bruce , John Baldwin , David Chisnall , Stephen Montgomery-Smith , Bruce Evans , Bruce Evans , David Schultz , Warner Losh Subject: Re: Use of C99 extra long double math functions after r236148 X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 12 Aug 2012 22:58:22 -0000 X-Original-Date: Thu, 19 Jul 2012 16:44:25 -0700 X-List-Received-Date: Sun, 12 Aug 2012 22:58:22 -0000 On Fri, Jul 20, 2012 at 07:39:44AM +1000, Peter Jeremy wrote: > On 2012-Jul-18 14:01:42 +1000, Bruce Evans wrote: > > >The standard classification macros are good for developing things, but > >they are very slow. All (?) committed complex functions use hard-coded > >bit test. > > I notice that the functions are full of hard-coded magic constants. > Would these be better as macros to: > 1) Provide a description as to their purpose; and > 2) Reduce differences between the float/long/double function bodies? > I collected some of the float and double into a cheat sheet. Idioms used in libm with float type: int32_t xsb; u_int32_t hx; GET_FLOAT_WORD(hx, x); /* Get the sign bit of x */ xsb = (hx >> 31) & 1; /* high word of |x| */ hx &= 0x7fffffff; /* NaN */ if (hx > 0x7f800000) return (x + x); /* exp(+-inf) = {inf, 0} */ if (hx == 0x7f800000) return (xsb == 0) ? x : 0.0; /* subnormal */ if (hx < 0x00800000) Idioms used in lib with double type: u_int32_t hx, lx, xsb EXTRACT_WORDS(hx, lx, x); /* sign bit of x */ xsb = (hx >> 31) & 1; /* high word of |x| */ hx &= 0x7fffffff; /* subnormal */ if (hx < 0x00100000) /* Test for NaN and +-Inf. */ if (hx >= 0x7ff00000) { /* Is it a NaN? */ if (((hx & 0xfffff) | lx) != 0) return (x + x); /* It's an +-Inf. */ return ((xsb == 0) ? x : 0.0); /* exp(+-inf)={inf,0} */ } -- Steve