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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4ff929aa5c2b2834 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ranges and (non)static constraints Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1msd2xaahtsgv.f8io255x4f0n$.dlg@40tude.net> <455db67b_1@glkas0286.greenlnk.net> <4561b3d2$1_1@glkas0286.greenlnk.net> <4561b4e1$1_1@glkas0286.greenlnk.net> Date: Mon, 20 Nov 2006 16:48:57 +0100 Message-ID: NNTP-Posting-Date: 20 Nov 2006 16:48:57 CET NNTP-Posting-Host: eae5a156.newsspool4.arcor-online.net X-Trace: DXC=`eRmMI@Dj_GlU`@c^jLCbJ4IUK On Mon, 20 Nov 2006 14:12:49 -0000, Stuart wrote: > "Stuart" wrote in message > news:4561b3d2$1_1@glkas0286.greenlnk.net... > >>> You mean: >>> type T is mod N; >>> subtype S is T range 1..N; >> >> Well, almost >> subtype S is T range 1..N-1; > > double Doh! > > type T is mod System.Max_Binary_Modulus; > subtype S is T range 1..N-1; > (many apologies; again) Unfortunately S is not a true integer type. For example, you will get no overflow upon wrapping. For example, when System.Max_Binary_Modulus = N, then S'Last+2 would result in 1. For the same reason, the subtype declaration should be rather: subtype S is T range 1..T(N-1); Otherwise it won't compile when N is not in T'Range, but N-1 is. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de