comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Size of 0..255 is not 8 bits?
Date: 1998/05/14
Date: 1998-05-14T00:00:00+00:00	[thread overview]
Message-ID: <dewar.895191168@merv> (raw)
In-Reply-To: matthew_heaney-ya023680001305982154260001@news.ni.net


Matthew says

<<type Value is range 0 .. 255;

definately requires 9 bits, so allowing the size clause

for Value'Size use 8;

is kind of confusing.
>>


More serious confusion on size! No, this is not "kind of confusing". It
is perfectly reasonable, and very useful to write

  type x is range 0 .. 3;
  for x'size use 2;

The size clause has nothing to do with the base values, which is where Matthew
is getting confused. The above size clause works just fine in conjunction
with pragma Pack, on an array, where you will get an array of 2 bit values
as expected.

The important thing to realize is that specifying a size for a type in
Ada 95 does not necesarily affect the size of objects of that type except
in the packed case. 

Howver, in a reasonable Ada 95 compiler, it is indeed the case that the
size clause for Value above should result in objects of type Value being
stored in 8 bits by default.





  parent reply	other threads:[~1998-05-14  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-14  0:00 Size of 0..255 is not 8 bits? Markus Kuhn
1998-05-13  0:00 ` Matthew Heaney
1998-05-14  0:00   ` Tom Moran
1998-05-14  0:00   ` Robert Dewar [this message]
1998-05-14  0:00   ` Markus Kuhn
1998-05-14  0:00     ` John McCabe
1998-05-14  0:00       ` Robert Dewar
1998-05-14  0:00     ` Robert Dewar
1998-05-14  0:00       ` Simon Pilgrim
1998-05-15  0:00       ` Markus Kuhn
1998-05-15  0:00         ` Samuel T. Harris
1998-05-15  0:00           ` Tucker Taft
1998-05-15  0:00       ` Joe Gwinn
1998-05-16  0:00         ` Robert Dewar
1998-05-17  0:00           ` Joe Gwinn
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox