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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,30e0ceaf4e6be70c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-10 17:55:02 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Simple program to find average of 3 numbers Date: Thu, 10 Jul 2003 19:56:36 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <6ZMNa.109291$0B.2183354@wagner.videotron.net> <1ec946d1.0307090725.73f5f200@posting.google.com> <3F0C8B45.2080108@attbi.com> <1ec946d1.0307100552.3fb220ac@posting.google.com> <3F0D8A17.2010407@attbi.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:40182 Date: 2003-07-10T19:56:36-05:00 List-Id: > Matthew Heaney wrote: > > With respect to the base range of the type, how do the declarations > > > > type T is new Integer range 1 .. 100; > > type T is range 1 .. 100; > > > > differ from one another? For the first, the base type is derived from Integer'Base. So T'Base'First = Integer'Base'First. OTOH, all we know about the second T is that T'First <= -100, and T'Last >= 100. (Generally, it is some power of two). Thus, the second gives more power to the compiler, and thus is preferred. For instance, Janus/Ada has historically used Integer'Size = 16 (that kept all of our compilers compatible -- probably a bad choice, but it is impossible to change without breaking a lot of user code). type T1 is Integer range 0 .. 100_000; -- Raises Constraint_Error on most versions of Janus/Ada; will work on GNAT, etc. type T2 is range 0 .. 100_000; -- Works fine on all modern versions of Janus/Ada. Randy. > Look at the output from the program I provided. In the first case, the > base type has the same characteristics as Integer'Base. In the second > example, look at the results of the program I ran. The compiler can > choose any predefined integer type for the base type. In this case, > GNAT choose one with a range -128..127. > -- > > Robert I. Eachus > > �In an ally, considerations of house, clan, planet, race are > insignificant beside two prime questions, which are: 1. Can he shoot? 2. > Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and > Steve Miller. >