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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6a77269912f77a70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-29 20:55:04 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!attbi_s52.POSTED!not-for-mail Message-ID: <3FA0999C.7080602@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why no 'Floor for fixed point types References: <3F99FBE1.1030601@comcast.net> <3F9AFB67.5080401@comcast.net> <3F9DC3D6.4010106@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.214.193 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s52 1067489698 24.34.214.193 (Thu, 30 Oct 2003 04:54:58 GMT) NNTP-Posting-Date: Thu, 30 Oct 2003 04:54:58 GMT Organization: Comcast Online Date: Thu, 30 Oct 2003 04:55:02 GMT Xref: archiver1.google.com comp.lang.ada:1838 Date: 2003-10-30T04:55:02+00:00 List-Id: Randy Brukardt wrote: > Read G.2.3 to see what the RM says about the accuracy of fixed point. > In particular, read about the 'perfect result set' and the 'close > result set'. If you care about accuracy, you need to avoid operations > which only require a result in the 'close result set', because those > are cases that the compiler is allowed to be inaccurate. Actually, there are cases that are allowed to use the close result set that no compiler goes out of their way to get inaccurate results on. But whether you limit yourself to the perfect result set, or are willing to accept some well-behaved cases in the close result set. My real point is that there are some pathological cases which no one cares about, and I doubt that any compiler does a perfect job of documenting. But that is fine with me. As I said, if you care, you check and for the compiler vendors to try and understand what code the compiler will generate in 2**93 cases (assuming only three 31-bit 'Smalls) is not something that I would want any compiler vendor to waste time on. In any case, the wierd/pathological whatever term you want to use cases are just not that usual. In the usual cases 1.0/fixed_type'Small is an integer for all three operands and A'Small/(B'Small * C'Small) is an integer as well. Of course, I am one of those nasty people who goes around doing things like measuring angles in microradians--and declaring a fixed point type with a 'Small to match. Technically, as declared 'Small is a rational number (2*Pi/1_000_000.0) since Ada.Numerics.Pi is only declared to 50 decimal places... But since 'Small is static, it is usally easy to see if the compiler did a good job of eliminating common factors to simplify the job. Incidently back in Ada 83 days Paul Hilfinger and I went round and around on when 2*actual precision or 3*actual precision was needed. I have implementation notes somewhere and Paul actually published a couple of papers. These are the calculations that the Ada 95 rules allow to be done using the close result set, and I think you can see that there are a few (as I said very pathological) cases where getting even close is difficult. I even have a program lying around with painful test cases. I never distributed it, because I was afraid it would end up in the ACVC/ACATS test. Remember the reason I was interested in these cases were entirely from a computational perspective. And if I don't care if compilers do them well, I don't see why anyone else should. (In one case I used two different power series expansions for Pi that agree to several thousand decimal places. And yes, they are written as universal integer expressions, so the compiler has to expand them exactly at compile time. I always thought it was funny when new computers would be used to compute a million digits of Pi or so. In Ada those programs are so fast they start printing the answer immediately. ;-) -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig