From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Need exception despite Machine_Overflows is false
Date: 1998/12/18
Date: 1998-12-18T00:00:00+00:00 [thread overview]
Message-ID: <m3hfuttkvv.fsf@mheaney.ni.net> (raw)
In-Reply-To: ug1ad8kyo.fsf@gsfc.nasa.gov
Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:
> Pascal MALAISE <malaise@magic.fr> writes:
>
> > Using gnat 3.10p on Linux,
> > I make several computations on long_float (s), then use a
> > text_io.float_io
> > to display the results => NaN*****
> >
> > There is an overflow, Gnat uses the libc, long_float'Machine_Overflows
> > is false...
> > fair enough.
> >
> > What can I do to get a constraint_error raised when there is an
> > overflow?
> > Don't tell me that I have to check, via an interface to C finite(), the
> > result of
> > each operation!
>
> You could try adding a range constraint to your basic floating point type:
>
> type Real is digits 9 range -1.0e307 .. +1.0e307;
>
> As long as your limits are tighter than the machine limits, the
> compiler will insert explicit checks. Of course, this will slow things
> down, but I assume you could remove the limits after you find the bug.
>
> This is one reason not to use the predefined Float type!
I think this statement is misleading.
The problem here has nothing to do with the "predefined Float type."
The "problem" is that an unconstrained type was used, when a constrained
type was desired. You would have the same problems if you did:
type My_Float is digits 6;
This declares an _unconstrained_ floating point subtype, meaning that no
constraint checks are performed.
Perhaps a better statement would be:
This is one reason not to use unconstrained floating point subtypes!
prev parent reply other threads:[~1998-12-18 0:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-17 0:00 Need exception despite Machine_Overflows is false Pascal MALAISE
1998-12-17 0:00 ` Matthew Heaney
1998-12-18 0:00 ` dewarr
1998-12-18 0:00 ` Matthew Heaney
1998-12-19 0:00 ` dewar
1998-12-18 0:00 ` Stephen Leake
1998-12-18 0:00 ` Pascal MALAISE
1998-12-19 0:00 ` dewarr
1998-12-18 0:00 ` Matthew Heaney [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox