comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: How to catch NaNs with gnat3.14p
Date: 3 Feb 2002 15:06:32 -0800
Date: 2002-02-03T23:06:33+00:00	[thread overview]
Message-ID: <5ee5b646.0202031506.3b21fba2@posting.google.com> (raw)
In-Reply-To: 3C5D2D77.288208B0@earthlink.net

"Marc A. Criley" <mcqada95@earthlink.net> wrote in message news:<3C5D2D77.288208B0@earthlink.net>...
> Robert Dewar wrote:
> > 
> >  Remember that float and long_float are
> > unconstrained types in Ada 95.
> 
> When I fully realized a few years ago that the predefined 
> Float type, unlike Integer, is an unconstrained type,

That's a bit misleading, the base range of all integer
types is also uncontrained (e.g. Integer'Base is unconstrained, and
you should routinely use Integer'Base
if you don't care about the extra range, since it can
generate more efficient code). Or, if you declare your
own type My_Int, then similarly use My_Int'Base.

 
> It.did make me wonder by what rationale Float'Last has a 
> value, since 'Last "denotes the upper bound
> of the range of S" [3.5 (13)].

That's confusing. The whole point of these types is that they have a
base range, see below, but this base range does not constrain the
range of possible values.

>  Of course in practical 
> implementations Float would have an upper bound,

Yes, but this upper bound has nothing to do with 'Last in
this case, see below.

> but the notion of an unconstrained type having an upper 
> bound seems awkward.

Indeed and there is no such notion in Ada 95, the whole
point of an unconstrained scalar base type is that it does
NOT have an upper bound from a semantic point of view. However they do
have a base range which has an upper bound,
but this upper bound is not the maximum possible stored
value.

The base range is defined as follows

6   The base range of a scalar type is the range of finite values of
the type that can be represented in every unconstrained object of the
type; it is also
the range supported at a minimum for intermediate values during the
evaluation of expressions involving predefined operators of the type.

Seems clear enough, and note that is quite different from
an upper bound, objects of the unconstrained base type can
(and often do, e.g. extra precision in fpt registers) have
results outside this base range and that's fine. So yes it
would be peculiar to have an upper bound for an unconstrained type,
and the *whole point* is that these
types do NOT have an upper bound, but it is still useful
to have a notion of guaranteed base range that is accomodated by *all*
objects of the unconstrained base type.

So in practice for example, the 'Last of Float is the
upper limit of 32-bit IEEE for a float object stored in
memory, but on the ia32, you might well use an 80-bit
extended float value in a register to represent a Float
object, and that would have a much much larger range.

Robert Dewar



  reply	other threads:[~2002-02-03 23:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-01 13:49 How to catch NaNs with gnat3.14p Alexander Boucke
2002-02-01 14:18 ` Preben Randhol
2002-02-01 14:37   ` Alexander Boucke
2002-02-01 14:55     ` Preben Randhol
2002-02-01 14:59       ` Alexander Boucke
2002-02-01 15:30         ` Preben Randhol
2002-02-01 16:10           ` Alexander Boucke
2002-02-01 16:10             ` Jeffrey Creem
2002-02-02  6:23               ` Robert Dewar
2002-02-02  6:21     ` Robert Dewar
2002-02-04  8:57       ` Alexander Boucke
2002-02-02  6:20   ` Robert Dewar
2002-02-02 12:49     ` Preben Randhol
2002-02-02 22:56       ` Robert Dewar
2002-02-01 20:22 ` Robert Dewar
2002-02-03 13:27   ` Marc A. Criley
2002-02-03 23:06     ` Robert Dewar [this message]
2002-02-04 13:05       ` Marc A. Criley
2002-02-05  1:06         ` Robert Dewar
replies disabled

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