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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a65079927bff9697 X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: 'Digit in generic package Date: 1996/08/27 Message-ID: <32231881.2A09@lmtas.lmco.com>#1/1 X-Deja-AN: 176831998 references: <9608261530.AA06035@most> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; 68K) Date: 1996-08-27T00:00:00+00:00 List-Id: W. Wesley Groleau (Wes) wrote: > > R. A. O'Keefe asked > [how to make a generic use the most precise type out of its actuals] > > R. Eachus answered > > [Write the generic body to dispatch at run-time] > > At least one vendor supplied a generic math package that did exactly > that AND on examining the disassembled code for an instantiation, we > found that the compiler had looked at the parameters and eliminated > the "dead code" so that the effect was exactly what Mr. O'Keefe had > asked for. If you have DEC Ada installed, you can look at the body of the generic SQRT routine in ADA$PREDEFINED:MATH_LIB.ADC and see: function SQRT (A: REAL) return REAL is begin if REAL'MACHINE_MANTISSA = SYSTEM.F_FLOAT'MACHINE_MANTISSA then return REAL(VAX_F.SQRT(F_FLOAT(A))); elsif REAL'MACHINE_MANTISSA = SYSTEM.D_FLOAT'MACHINE_MANTISSA then ... Usually, this gets optimized to a simple call to the pre-defined VAX SQRT routine of the appropriate precision. -- LMTAS - "Our Brand Means Quality"