From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d575f572a099528 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-10 09:35:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!hub1.nntpserver.com!sjcppf01!usenetserver.com!news-west.rr.com!news-east.rr.com!chnws02.mediaone.net!chnws06.ne.mediaone.net!24.128.8.70!typhoon.ne.mediaone.net.POSTED!not-for-mail From: "Jeff Creem" Newsgroups: comp.lang.ada References: <3c08314d$0$158$9b622d9e@news.freenet.de> <3C0BA624.7A12BFA1@boeing.com> <3C10C26B.AA451459@nbi.dk> <3C10F77E.6BDD9A3B@nbi.dk> <5ee5b646.0112090427.1a26ecde@posting.google.com> <3C14E817.8A2E798E@nbi.dk> Subject: Re: What is faster Ada or C? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Message-ID: Date: Mon, 10 Dec 2001 17:33:16 GMT NNTP-Posting-Host: 24.61.92.65 X-Complaints-To: abuse@mediaone.net X-Trace: typhoon.ne.mediaone.net 1008005596 24.61.92.65 (Mon, 10 Dec 2001 12:33:16 EST) NNTP-Posting-Date: Mon, 10 Dec 2001 12:33:16 EST Organization: ATT Broadband Xref: archiver1.google.com comp.lang.ada:17697 Date: 2001-12-10T17:33:16+00:00 List-Id: Note that if you are really interested in the performance difference of the two discussed square roots you may want to look for a few minutes at the instruction set of your computer and your problem domain since there is sometimes an instruction that calculates the 1/sqrt(x) which can then be used in places where you had code like Y := B / SQRT(X) which can now be Y := B * my_sqrt_recip(X). If your processor has and instruction like this it can save a few cycles. I use this as an example but there may be other cases where things like this can be found. A small package machine_code coded special purpose math library can sometimes really help in tight loops. (And of course it can be a fun waste of time in not so tight loops :) "Jacob Sparre Andersen" wrote in message news:3C14E817.8A2E798E@nbi.dk... > Robert Dewar wrote: > > > Jacob Sparre Andersen wrote in message news:<3C10F77E.6BDD9A3B@nbi.dk>... > > > When I look at the corresponding assembler code (gnatgcc > > > -S/g++ -S) I can see that GNU C++ inlines the square root > > > function, while GNU Ada doesn't. > > > > You seem to be assuming that the function called square root in C++ > > and the function called square root in Ada > > are the same function, > > Correct. > > > presumably because their names > > are similar, and both are usable in your context, but they > > are not at all the same routine. The Ada routine has additional > > semantics not present in the C++ routine (e.g. > > the handling of -0.0 which is required to return -0.0). > > I had forgotten (or had not noticed) this. > > > Those extra tests take significant time. Now one can sit > > back and say "Ada is a junk language, it insists on testing > > for errors at runtime, and in giving accurate IEEE results, > > and I don't need either", > > I happen to need accurate results, and I appreciate being > able to specify things like the number of significant digits > in my floating point types. But I am (as a physicist) not > used to -0.0 being different from +0.0, nor to being unable > to calculate the square root of -0.0, as your explanations > seem to indicate that IEEE floating point processors are. > > > but that's not a very reasonable > > position given that if you like you can easily call the > > C routine directly, since Ada, unlike other languages, > > carefully defines the syntax and semantics of calling routines written > > in other languages :-) > > Since I - in the example program - know that the values will > never get close to zero, I suppose that I can use the C > function "sqrt". > > Jacob > -- > I teorien lyver folk ikke i retten.