From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Question about base types
Date: 1997/02/07
Date: 1997-02-07T00:00:00+00:00 [thread overview]
Message-ID: <32FB5B4A.1B95@elca-matrix.ch> (raw)
In-Reply-To: dewar.855276722@merv
> << << type Real is digits 7 range 0.0 .. 1.0;
> << << package Actual is new Example (Real =<< Real);
> << <<
> << << The implementation of Op needs to be able to do calculations independent
> << << of any range constraint on the actual parameter associated with the
> << << formal parameter Real. So it does its calculations using Real'Base:
> << <<
> << << function Op (Arg : Real) return Real is
> << << Result : Real'Base := Arg + 27.0;
> <<
> << This could fail (i.e. raise Constraint_Error), since 27.0 is not
> << required to be in the range of Real'Base. But it will work on most
> << machines because on reasonable implementations, floating point types are
> << mapped to representations that the hardware can handle efficiently (e.g.
> << IEEE). >>
>
> This is a little misleading. While it is true that, unlike the case in
> Ada 83, where of course the base type of type Real must have a big range,
> the definitions of Ada 95 DO allow a narrow range IF that is what the
> hardware provides (I am assuming annex G is implemented). Since there are
> no machines with floating point types with 7 digits of precision and a
> range that does not include 27.0, nor could there ever be such machines,
> to worry about this eventuality is as silly as worrying about the fact
> that a legal Ada implementation could raise storage_Error for every
> possible program.
True. But if you know that you are going to need larger intermediate
results, then I think it is wiser to declare
type Real_Base is digits 7;
subtype Real is Real_Base range 0.0 .. 1.0;
than
type Real is digits 7 range 0.0 .. 1.0;
next prev parent reply other threads:[~1997-02-07 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 ` Mats Weber
1997-01-28 0:00 ` Robert A Duff
1997-01-29 0:00 ` Robert Dewar
1997-01-27 0:00 ` Robert A Duff
1997-01-30 0:00 ` Matthew Heaney
1997-01-30 0:00 ` Matthew Heaney
1997-01-30 0:00 ` Robert Dewar
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 [this message]
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-28 0:00 ` Robert I. Eachus
1997-01-28 0:00 ` Mats Weber
1997-01-29 0:00 ` Robert I. Eachus
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