From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: Ada83/95 Compatibility
Date: Wed, 14 Dec 2005 06:18:03 GMT
Date: 2005-12-14T06:18:03+00:00 [thread overview]
Message-ID: <vOOnf.3924$Tg2.2242@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <1134499582.913837.213460@g43g2000cwa.googlegroups.com>
jeff@thecreems.com wrote:
> type My_Big_Int is range -2**31 .. 2**31 -1 ;
> for My_Big_Int'size use 32;
>
> subtype little_range is My_Big_Int range 0 .. 255;
>
> A : My_Big_Int;
> B : Little_Range;
>
> I was not surprised that Little_Range'size = 8
>
> What surprised me was that b'size comes back as 8. I've re-read the
> representation chapter again and I think the compiler is probably
> within its rights to do this.
This seems correct to me. A value of subtype Little_Range can be stored in 8
bits (hence its 'Size is 8). What's important is that operations on values of
Little_Range are done using My_Big_Int'Base.
If you need to store a value in 32 bits (for interfacing to HW, for example) but
be sure it's in Little_Range, you can always specify the 'Size of the object:
X : Little_Range;
for X'Size use My_Big_Int'Size;
--
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71
next prev parent reply other threads:[~2005-12-14 6:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-13 18:46 Ada83/95 Compatibility jeff
2005-12-14 6:18 ` Jeffrey R. Carter [this message]
2005-12-15 0:14 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox