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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7dac35d19d7d0d84 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-14 07:48:48 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!feed.news.nacamar.de!newsfeed.vmunix.org!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Getting modular type size in bits Date: Fri, 14 Mar 2003 15:48:48 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1047656928 20016 217.17.192.37 (14 Mar 2003 15:48:48 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Fri, 14 Mar 2003 15:48:48 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:35324 Date: 2003-03-14T15:48:48+00:00 List-Id: * Robert A Duff wrote: > Jano <402450@cepsz.unizar.es> writes: >> I want to know that the type size is 5. I'm aware of the 'modulus >> attribute, and 'size. If I understand correctly, 'size returns the size >> allocated by the compiler for the type (normally 8 in this case), not >> the _minimum_ size to allocate it (which is what I would need in that >> case). > > 'Size returns the minimum -- i.e. how big it would be if it were a > component of a packed record. That's 32 in this case. If it were > "mod 2**5", then Number'Size would be 5, not 8. $ cat t.adb with Ada.Text_IO; procedure t is type A is mod 2**5; for A'Size use 8; begin Ada.Text_IO.Put_Line(Natural'Image(A'Size)); declare type B is new A; begin Ada.Text_IO.Put_Line(Natural'Image(B'Size)); end; end t; $ ./t 8 8 $ _