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 18:37:31 PST Path: newsfeed.google.com!newsfeed.stanford.edu!headwall.stanford.edu!news-out.nibble.net!news-in.nibble.net!telocity-west!TELOCITY!newsrump.sjc.telocity.net!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: <9d1eai$3nf$1@eol.dd.chalmers.se> Subject: Re: Catching NaN .. not a number MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: X-Trace: oqe32fjW4uP/wuTy5bfD0tvY1N7DzrrF0tbT0sXEt6WmobmlpaC5o6C5o663t9r4+bu3p6C32vbu!t6Wnp6a3pq+tpKCtpKe3x9PD X-Abuse-Info: Please forward ALL headers when reporting abuse. X-Complaints-To: abuse@telocity.net NNTP-Posting-Date: Mon, 07 May 2001 18:37:30 PDT Date: Mon, 7 May 2001 20:37:33 -0500 Xref: newsfeed.google.com comp.lang.ada:7294 Date: 2001-05-07T20:37:33-05:00 List-Id: As I posted Saturday, May 5: Catching NaN requires a three-way test, viz.: if Value /= 0.0 and then (not (Value < 0.0)) and then (not (Value > 0.0)) then ; end if; "Stephen Leake" wrote in message news:uelu0on1n.fsf@gsfc.nasa.gov... > 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