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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no 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-04 14:02:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!opentransit.net!wanadoo.fr!not-for-mail From: "Bertrand Augereau" Newsgroups: comp.lang.ada Subject: Re: What is faster Ada or C? Date: Tue, 4 Dec 2001 23:05:25 +0100 Organization: Wanadoo, l'internet avec France Telecom Message-ID: <9ujh51$k6m$1@wanadoo.fr> References: Reply-To: "Bertrand Augereau" NNTP-Posting-Host: afontenayssb-103-1-6-53.abo.wanadoo.fr X-Trace: wanadoo.fr 1007503329 20694 80.13.152.53 (4 Dec 2001 22:02:09 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 4 Dec 2001 22:02:09 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:17414 Date: 2001-12-04T22:02:09+00:00 List-Id: > One micro example -- SQRT. Using Apex and > Numerics.Generic_Elementary_Functions the SQRT function is faster in Ada > than in C on any target system with hardware SQRT. This is because C > uses a library call to get to the function, while with Ada it is > possible to use Machine_Code and inlining to just "use" the machine > instruction. Further, for single-precision SQRT, C must promote the > single-precision to double-precision, do the SQRT, and then demote the > result. In Ada, the single-precision SQRT machine instruction is all > that appears in the code listing. Practically, I've never used a C++ compiler where you couldn't declare an inline assembly function (g++, intel c++, vc++, mwcw) Moreover, you have float sqrtf(float) which allows you not to use double sqrt(double) (it sometimes can be costly, ie PSX2) But I suppose those have been there since longer in Ada.