From owner-freebsd-numerics@FreeBSD.ORG Sun Sep 16 17:12:15 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 67E6A106564A for ; Sun, 16 Sep 2012 17:12:15 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id E908D8FC0C for ; Sun, 16 Sep 2012 17:12:14 +0000 (UTC) Received: from c122-106-157-84.carlnfd1.nsw.optusnet.com.au (c122-106-157-84.carlnfd1.nsw.optusnet.com.au [122.106.157.84]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q8GHC7nQ019965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Sep 2012 03:12:07 +1000 Date: Mon, 17 Sep 2012 03:12:07 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Stephen Montgomery-Smith In-Reply-To: <5055EE33.2090400@missouri.edu> Message-ID: <20120917025148.X2943@besplex.bde.org> References: <5017111E.6060003@missouri.edu> <20120814201105.T934@besplex.bde.org> <502A780B.2010106@missouri.edu> <20120815223631.N1751@besplex.bde.org> <502C0CF8.8040003@missouri.edu> <20120906221028.O1542@besplex.bde.org> <5048D00B.8010401@missouri.edu> <504D3CCD.2050006@missouri.edu> <504FF726.9060001@missouri.edu> <20120912191556.F1078@besplex.bde.org> <20120912225847.J1771@besplex.bde.org> <50511B40.3070009@missouri.edu> <20120913204808.T1964@besplex.bde.org> <5051F59C.6000603@missouri.edu> <20120914014208.I2862@besplex.bde.org> <50526050.2070303@missouri.edu> <20120914212403.H1983@besplex.bde.org> <50538E28.6050400@missouri.edu> <20120915231032.C2669@besplex.bde.org> <50548E15.3010405@missouri.edu> <5054C027.2040008@missouri.edu> <5054C200.7090307@missouri.edu> <20120916041132.D6344@besplex.bde.org> <50553424.2080902@missouri.edu> <20120916134730.Y957@besplex.bde.org> <5055ECA8.2080008@missouri.edu> <5055EE33.2090400@missouri.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-numerics@FreeBSD.org Subject: Re: Complex arg-trig functions 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: , X-List-Received-Date: Sun, 16 Sep 2012 17:12:15 -0000 On Sun, 16 Sep 2012, Stephen Montgomery-Smith wrote: > A style question: do you mind this > > if (sy==0) ry = copysign(ry, -1); > if (A < 1) A = 1; > > or do you prefer > > if (sy==0) > ry = copysign(ry, -1); > if (A < 1) > A = 1; Multiple statements per line are large style bugs, as are missing spaces around == operators (I might agree only to omitting spaces around most multiplication operators and some addition operators). Apart from being less readable, multiple statements per line break debugging using line-based debuggers. BTW, copysign() is builtin in gcc-4.2 and not broken by a macro in . Otherwise it would be very slow. BTW2, fdlibm avoids using copysign() internally, but often sets sign bits by a direct bit access which does the equivalent of what copysign() does semantically. This can be slow, since it best it takes a read-modify-write of the target with all 3 steps in this non- parallelizable. Another not so good way to set sign bits is use an array with enties +-1 and do `ry *= array[sy];' Branchy code for setting or clearing the sign bit may be better then either of these methods, at least if the branches are predictable. If the builtin is very smart, then it will treat the copysign() call as a hint and select the best alternative, and it can do this more easily than it can rewrite manually optimized sequences for setting sign bits. I think it is not very smart. Bruce