From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Getting modular type size in bits
Date: 14 Mar 2003 12:20:20 -0500
Date: 2003-03-14T12:20:20-05:00 [thread overview]
Message-ID: <wccznnxrhkb.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: slrnb73uer.o1.lutz@taranis.iks-jena.de
Lutz Donnerhacke <lutz@iks-jena.de> writes:
> * 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
> $ _
So? You asked for 8, and you got 8. And it will be (at least) 8 bits
in a packed record. If you take out the "for A'Size ...", which was not
in the original poster's example, it should be 5.
- Bob
next prev parent reply other threads:[~2003-03-14 17:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-14 15:03 Getting modular type size in bits Jano
2003-03-14 15:41 ` Robert A Duff
2003-03-14 15:48 ` Lutz Donnerhacke
2003-03-14 17:20 ` Robert A Duff [this message]
2003-03-14 21:05 ` Jano
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox