Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!brl-adm!seismo!rochester!pt.cs.cmu.edu!sei.cmu.edu!firth From: firth@sei.cmu.edu.UUCP Newsgroups: comp.lang.c Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x) Message-ID: <544@aw.sei.cmu.edu.sei.cmu.edu> Date: Mon, 9-Feb-87 08:46:38 EST Article-I.D.: aw.544 Posted: Mon Feb 9 08:46:38 1987 Date-Received: Tue, 10-Feb-87 04:45:56 EST References: <4943@mimsy.UUCP> <2550005@hpisod2.HP> <756@unc.unc.UUCP> <2181@batcomputer.tn.cornell.edu> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (PUT YOUR NAME HERE) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 20 In article <2181@batcomputer.tn.cornell.edu> braner@batcomputer.UUCP (braner) writes: >THE COMPLETE FP LIBRARY MUST BE WRITTEN IN HAND-OPTIMIZED ASSEMBLER LANGUAGE!!! > >- Moshe Braner Let me scoond this cry! Most C mathlibs are indeed very bad. I recall running a mathematical benchmark through a supposedly optimising compiler and finding negligible difference in runtime relative to the portable-C compiler generated code. Turned out the benchmark was spending 95% of its time computing sqrt. We recoded sqrt in Assembler and reduced its runtime by a factor of 20. As a bonus, it even returned the correct results. I then looked at sin, cos, log &c and... and you really don't want to know what they were like. As a very small nitpick with Moshe, your hand-optimised fabs should of course check for infinity and NaNs rather than just clearing the "sign bit". On the PDP-11, for instance, the BIC trick turns "reserved operand" into "zero", and some programmer who cared about detecting uninitialised variables loses badly.