From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ranges and (non)static constraints
Date: Mon, 20 Nov 2006 16:48:57 +0100
Date: 2006-11-20T16:48:57+01:00 [thread overview]
Message-ID: <okl3tiwmv3yi$.1kkbfro7drlmx.dlg@40tude.net> (raw)
In-Reply-To: 4561b4e1$1_1@glkas0286.greenlnk.net
On Mon, 20 Nov 2006 14:12:49 -0000, Stuart wrote:
> "Stuart" <stuart@0.0> 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
next prev parent reply other threads:[~2006-11-20 15:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-16 11:02 Ranges and (non)static constraints Maciej Sobczak
2006-11-16 12:23 ` Martin Krischik
2006-11-16 13:23 ` Maciej Sobczak
2006-11-16 19:01 ` Jeffrey R. Carter
2006-11-18 0:02 ` Robert A Duff
2006-11-16 13:13 ` Dmitry A. Kazakov
2006-11-16 17:18 ` Jean-Pierre Rosen
2006-11-17 9:08 ` Dmitry A. Kazakov
2006-11-17 10:30 ` Stuart
2006-11-17 10:37 ` Jean-Pierre Rosen
2006-11-17 14:57 ` Dmitry A. Kazakov
2006-11-17 16:04 ` Jean-Pierre Rosen
2006-11-18 9:51 ` Dmitry A. Kazakov
2006-11-18 14:17 ` Stephen Leake
2006-11-17 20:05 ` Jeffrey R. Carter
2006-11-17 23:58 ` Robert A Duff
2006-11-18 9:47 ` Dmitry A. Kazakov
2006-11-19 2:27 ` Jeffrey R. Carter
2006-11-19 12:13 ` Björn Persson
2006-11-19 22:51 ` Robert A Duff
2006-11-20 3:51 ` Jeffrey R. Carter
2006-11-21 21:02 ` Robert A Duff
2006-11-20 17:35 ` Adam Beneschan
2006-11-17 15:45 ` Maciej Sobczak
2006-11-17 16:45 ` Jean-Pierre Rosen
2006-11-17 10:39 ` AW: " Grein, Christoph (Fa. ESG)
2006-11-17 11:20 ` Dmitry A. Kazakov
2006-11-17 13:30 ` Stuart
2006-11-17 15:07 ` Dmitry A. Kazakov
2006-11-17 16:47 ` Jean-Pierre Rosen
2006-11-20 14:08 ` Stuart
2006-11-20 14:12 ` Stuart
2006-11-20 15:48 ` Dmitry A. Kazakov [this message]
2006-11-16 18:56 ` Jeffrey R. Carter
2006-11-16 20:00 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox