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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,78ec96be17741f16 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Unclear error message - please help Date: 09 Oct 2005 10:24:16 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <432C8690.C37D4AE0@alfred-hilscher.de> <43482077.3434FCF3@alfred-hilscher.de> <4894486.ZC6T0HgaI8@linux1.krischik.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1128867856 27900 192.74.137.71 (9 Oct 2005 14:24:16 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 9 Oct 2005 14:24:16 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5526 Date: 2005-10-09T10:24:16-04:00 List-Id: Martin Krischik writes: > Alfred Hilscher wrote: > > > subtype > > Sixteen_Bits is Integer range 0..65535; > > The name "Sixteen_Bits" suggest a different implementation: > > type Sixteen_Bits is mod 2 ** 16; > for Sixteen_Bits'Size use 16; > > A "range 0..65535" needs 17 bits and an "is Integer" is usually 32 bit. I don't really agree with that advice. Modular types should be used only in certain rare circumstances. (They are, perhaps, my least favorite feature of Ada.) Anyway, Sixteen_Bits is 16 bits. I mean, Sixteen_Bits'Size = 16. There's no implementation choice here -- that's required of all implementations. And you can use rep clauses or pragmas Pack to ensure that objects of this subtype are actually allocated 16 bits. Without such clauses or Pack, the compiler is free to do whatever it likes -- probably allocate 32 bits for each object. 17 bits is pretty unlikely! ;-) Arithmetic will be done in the base range, however -- you'll get overflows past Integer'First..Integer'Last, not 0..2**16-1. > See > > http://en.wikibooks.org/wiki/Ada_Programming/Types/range > http://en.wikibooks.org/wiki/Ada_Programming/Types/mod > > for more info. - Bob