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,30e0ceaf4e6be70c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-07 22:06:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail From: vashwath@rediffmail.com (prashna) Newsgroups: comp.lang.ada Subject: Re: Simple program to find average of 3 numbers Date: 7 Jul 2003 22:06:28 -0700 Organization: http://groups.google.com/ Message-ID: References: <6ZMNa.109291$0B.2183354@wagner.videotron.net> NNTP-Posting-Host: 203.90.112.53 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1057640788 19797 127.0.0.1 (8 Jul 2003 05:06:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 8 Jul 2003 05:06:28 GMT Xref: archiver1.google.com comp.lang.ada:40125 Date: 2003-07-08T05:06:28+00:00 List-Id: > you shoud declare your type "one_to_100" differently... > this should work better: > ------------------------------------------------------- > procedure Average is > > type One_To_100 is new Integer range 1 .. 100; > > Obj1, > Obj2, > Obj3, > Avg : One_To_100; > > begin > Obj1 := 70; > Obj2 := 70; > Obj3 := 70; > AVG := (OBJ1+OBJ2+OBJ3)/3; > end Average; > > ------------------------------------------------------- > > you will get a constraint error only when the sum of OBJ1+OBJ2+OBJ3 will > reach a number higher than the highest permited value in the Integer > type (2**15-1 if iremember well) > > gilles Thanks every one for the replies. Among these two type declarations which is better one?In my opinion declaring a type as derived type of another type (integer in this case) is better one because the intermediate results of arithmetic operations will be stored as integer type or Is there any advantage of declaring a type as just a values within certain range (ex:type ONE_TO_100 is range 1 .. 100;)? Thanks