From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,734832b8ad479964 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-07 14:45:34 PST Path: newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Catching NaN .. not a number Date: 07 May 2001 17:40:36 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <9d1eai$3nf$1@eol.dd.chalmers.se> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 989272566 2762 128.183.220.71 (7 May 2001 21:56:06 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 7 May 2001 21:56:06 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: newsfeed.google.com comp.lang.ada:7288 Date: 2001-05-07T21:56:06+00:00 List-Id: Keith Thompson 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