From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: Tue, 19 Nov 91 10:06:01 EST From: "Norman H. Cohen" Subject: Re: Red-faced professor gets bitten in search for portability Message-ID: <9111191534.AA20295@ajpo.sei.cmu.edu> List-Id: In article <1991Nov15.185959.5002@milton.u.washington.edu> mfeldman@milton.u.washington.edu (Michael Feldman) describes the difficulty in implementing a portable Trunc function in Ada. He shows a solution involing integer division and writes that this solution > ... seems like a >kludgy way to do a simple truncation. I think this is an example of >an operation that's much more easily done as an intrinsic than as >a programmer-defined function. > >Any thoughts in net-land? This is one of the primitive functions that the Numerics Rapporteur Group of ISO-IEC/JTC1/SC22/WG9 is now working on, with the goal of establishing an ISO standard Generic Primitive Functions package. (Do not confuse this with the Generic Elementary Functions package, which has, if I recall correctly, already been submitted to SC22 as a draft standard. The primitive functions are operations like truncation, determining the exponent of a floating-point number, determining the mantissa of a floating-point number, and so forth. They are most straightforwardly implemented by dealing directly with the target machine's floating-point representation, so compilers are likely to treat these functions as intrinsics, replacing calls to them with inline code. The elementary functions are higher-level operations like the trig functions, logarithms, and square root, which can be implemented portably in terms of the elementary functions.) > By the way - I am all the more red-faced because I let the dangerous > Trunc monster loose into a textbook. 'Course, I haven't run into > another Ada text that even discusses the question... Don't lose sleep over it! I presume (pray) that no safety-critical application will incorporate an algorithm from any textbook without further careful scrutiny. Compared to the flub in Dr. Ruth's book (incorrectly describing the time of the month at which a woman can conceive as the time at which the risk of pregnancy is LOWEST), this is no big deal. Norman H. Cohen