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=-0.9 required=5.0 tests=BAYES_00,FROM_NUMERIC_TLD autolearn=no 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-04 04:10:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!lore.csc.com!baen1673807.greenlnk.net!baen1673807!not-for-mail From: Stuart Palin Newsgroups: comp.lang.ada Subject: Re: Simple program to find average of 3 numbers Date: Fri, 04 Jul 2003 12:02:54 +0100 Organization: Computer Sciences Corporation Message-ID: <3F055EDE.A213E474@0.0> References: NNTP-Posting-Host: 20.44.240.3 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: lore.csc.com 1057316576 25857 20.44.240.3 (4 Jul 2003 11:02:56 GMT) X-Complaints-To: abuse@news.csc.com NNTP-Posting-Date: Fri, 4 Jul 2003 11:02:56 +0000 (UTC) X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en X-Original-NNTP-Posting-Host: rc2966.rochstr.gmav.gecm.com X-Original-Trace: 4 Jul 2003 12:00:22 +0100, rc2966.rochstr.gmav.gecm.com Xref: archiver1.google.com comp.lang.ada:40053 Date: 2003-07-04T12:02:54+01:00 List-Id: prashna wrote: > O.K, I have changed line 12 to AVG := (OBJ1+OBJ2+OBJ3)/3; > But still it giving constraint error!!! :(( Having another look at your original posting, notice that there is a difference between the way you have declared your type and the way it is declared in Robert Eachus' example. Do you get the exception with Robert's example? If not what might be the underlying difference? Think again about the points I raised earlier: > You might also want to consider what values the intermediate > calculation Obj_1+Obj_2+Obj_3 can take. OK, the second sentence really applies to Robert's example... > In this instance because your type is constrained to a > number which should be well within the bounds of integer > you would not experience a problem. What context might the expression be evaluated in in your example? (Think about 'base types' try ranges of 1..42 and 1..43 [with suitable initial values]. What interesting number lies between 3*42 and 3*43?) How might it be possible to detect a potential constraint error at compile time rather than during execution? -- Stuart Palin