From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Catching NaN .. not a number
Date: 07 May 2001 17:40:36 -0400
Date: 2001-05-07T21:56:06+00:00 [thread overview]
Message-ID: <uelu0on1n.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: yecg0ej5uub.fsf@king.cts.com
Keith Thompson <kst@cts.com> writes:
> f97stdi@dd.chalmers.se (Staffan Dittmer) writes:
> > Did some calcualtions during the night and
> > ended up with an output file full of NaN - due to
> > overflow when calculating a factorial.
> >
> > A bit surprised by this since I thought a Constraint Error
> > would be raised.
>
> An implementation isn't required to raise Constraint_Error on
> floating-point overflow or division by zero. See the
> Machine_Overflows attribute.
>
> > So, how do I catch a NaN result ?
>
> I don't think there's a standard way to do so; see the documentation
> for your implementation.
X'Valid should catch it; see ARM 13.9.2
And it works in GNAT 3.14a:
with Ada.Text_IO; use Ada.Text_IO;
procedure NAN
is
Zero : Float := 0.0;
A_NAN : Float := 1.0 / Zero;
begin
Put_Line ("A_NAN'Valid => " & Boolean'Image (A_Nan'Valid));
end NAN;
generates:
A_NAN'Valid => FALSE
--
-- Stephe
next prev parent reply other threads:[~2001-05-07 21:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-05 17:46 Catching NaN .. not a number Staffan Dittmer
2001-05-05 17:58 ` Preben Randhol
2001-05-05 18:28 ` Staffan Dittmer
2001-05-05 21:50 ` Keith Thompson
2001-05-07 21:40 ` Stephen Leake [this message]
2001-05-08 1:37 ` David C. Hoos, Sr.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox