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: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,899fc98b2883af4a X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-ArrivalTime: 2003-05-20 20:05:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail Message-ID: <3ECAECFC.8050202@attbi.com> 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.java.advocacy,comp.object,comp.lang.ada,comp.software-eng Subject: Re: Logic Errors and Ada References: <9fa75d42.0304230424.10612b1a@posting.google.com> <254c16a.0305140549.3a87281b@posting.google.com> <9fa75d42.0305141747.5680c577@posting.google.com> <1053027582.984315@master.nyc.kbcfp.com> <3ec4b5c5$1@news.wineasy.se> <254c16a.0305160930.40bb42f9@posting.google.com> <9fa75d42.0305181502.53703035@posting.google.com> <3EC83ABB.60702@attbi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.62.164.137 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc01 1053486337 24.62.164.137 (Wed, 21 May 2003 03:05:37 GMT) NNTP-Posting-Date: Wed, 21 May 2003 03:05:37 GMT Organization: AT&T Broadband Date: Wed, 21 May 2003 03:05:37 GMT Xref: archiver1.google.com comp.lang.java.advocacy:64310 comp.object:63783 comp.lang.ada:37574 comp.software-eng:19325 Date: 2003-05-21T03:05:37+00:00 List-Id: Peter Hermann wrote: > thank you, Robert, for your excellent contribution: > you should have sent it a couple of years sooner ;-) > OTOH, thanks to Ada it is quite easy to update my code > http://www.csv.ica.uni-stuttgart.de/homes/ph/adapilotresources/basic_tools/coords.ads > for enhanced precision. It probably would not have worked. In Ada83 there was an unintentional glitch in the definition of the multiply operator for fixed point types that made it a pain for compilers to accept "arbitrary" specifications of 'Small. This was all the more painful because a programmer might never create the horrible case, but compilers had to reject the type declaration if they couldn't handle all possible cases where types with different 'Smalls were used in one multiplication. I won't go into the gory details, but there were a few cases which required triple precision integer arithmetic at run time. No one really wanted to use those operations, but the easiest thing for implementors to do was to reject many specifications of 'Small. In Ada95 the rules were change slightly. But IMHO, the bigger change was that all implementors were reassured that if a weird case not covered by the rules showed up, the intent was to fix the rules, not punish implementors. Add to that the new decimal types which require some support for non-powers-of-two 'Small, and AFIAK all Ada compilers now support the most important case: 1.0/X where X is a (32-bit) integer. Oh, and I really do mean integer there. Division of 1.0 by a universal integer is legal in Ada. I don't know if any compilers are not smart enough to figure out that 1.0/360000.0 should mean the same thing. It is so easy to ask for what I want (X * My_Type'Small = 1.0 exactly). So I do that instead of asking for something else and hoping the compiler will figure it out. > For storage reasons I could?should offer different types of precision. I can't see why. Most likely unless you really want to try to force the compiler to use 16-bit representations, you will get a 32-bit object. Hundreths of a second gets you, what, about one foot accuracy? (Technically, a compiler should be able to support 1/2000 of a degree in latitude and 1/1000 in longitude, but I have never tried it.)