comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Question about base types
Date: 1997/01/29
Date: 1997-01-29T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.97Jan29150858@spectre.mitre.org> (raw)
In-Reply-To: mheaney-ya023280002601971414080001@news.ni.net



   I said: 

   >   No.  The range of the anonomous type must be at least -15..15, but
   > the actual range is implementation dependent.

In article <32EE1434.3BB4@elca-matrix.ch> Mats Weber <Mats.Weber@elca-matrix.ch> writes:

   > I think this should be -10 .. 10. Nothing in the RM says it must be a
   > power of two minus one.

   Sigh, think of it as a ramification. ;-) You are correct that the
RM no longer requires that the range be based on a power of two, but
the rules for the attribute 'SIZE get mixed in here.  Since T'SIZE is
in (integer) bits, it must be 4 or greater (see 13.3).  Any range that
includes 1..10 is legal, including -5..10.  But T'BASE'SIZE must be at
least 5, because of the rule about symmetric ranges.  So there are at
least 31 possible values for an object of type T'BASE.  (Thirty-one?
Yep, thirty-one.  This is due to the dispensation for ones-complement
machines to allow for two zeros.)

   Since the anonymous type is unconstrained and contains all the
legal values of an object of type T'BASE, that means that there must
be at least 31 possible values, again distributed symmetrically around
zero, but there can be more.  And since the attribute is defined for
subtypes and objects, not types, it is possible for the size in bits
of an anonymous type to be log2(100) for example.  So minus one
hundred to ninety-nine would be a possible range, but minus ten to ten
would not be.

    Does this say that you can't put objects of (sub)type T in one
digit on a decimal machine?  No.  It says that objects of type T'BASE
sometimes require more space than objects of type T.  This has always
been a known ramification in Ada 83.  (In Ada 83 it only came up for
loop variables, in Ada 95 it can appear in lots of other places.)

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1997-01-29  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-26  0:00 Question about base types Matthew Heaney
1997-01-27  0:00 ` Robert A Duff
1997-01-30  0:00   ` Matthew Heaney
1997-01-30  0:00     ` Robert Dewar
1997-01-30  0:00       ` Matthew Heaney
1997-01-30  0:00     ` Matthew Heaney
     [not found]     ` <EACHUS.97Feb3221558@spectre.mitre.org>
     [not found]       ` <dewar.855063927@merv>
     [not found]         ` <EACHUS.97Feb6145918@spectre.mitre.org>
     [not found]           ` <dewar.855276722@merv>
1997-02-07  0:00             ` Mats Weber
1997-02-08  0:00               ` Robert Dewar
1997-02-10  0:00                 ` Mats Weber
1997-02-11  0:00                   ` Robert Dewar
     [not found]         ` <32FB45D4.2160@watson.ibm.com>
1997-02-10  0:00           ` Robert Dewar
1997-02-08  0:00   ` Robert Dewar
1997-02-09  0:00     ` Matthew Heaney
1997-02-09  0:00       ` Robert Dewar
1997-02-09  0:00         ` Matthew Heaney
1997-02-10  0:00           ` Robert Dewar
1997-02-10  0:00       ` Larry Kilgallen
1997-02-11  0:00   ` Robert I. Eachus
1997-02-12  0:00     ` Robert Dewar
1997-01-27  0:00 ` Mats Weber
1997-01-28  0:00   ` Robert A Duff
1997-01-29  0:00   ` Robert Dewar
1997-01-28  0:00 ` Robert I. Eachus
1997-01-28  0:00   ` Mats Weber
1997-01-29  0:00 ` Robert I. Eachus [this message]
1997-01-30  0:00   ` Robert A Duff
replies disabled

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