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-Thread: 103376,772ddcb41cd06d5b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!postnews.google.com!p25g2000pri.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: How to check a Float for NaN Date: Thu, 1 May 2008 17:04:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <13e5c71c-627a-4176-891b-4371949565b4@p25g2000pri.googlegroups.com> References: <3132e38d-18bb-4890-9cec-31056ac6e3ba@x19g2000prg.googlegroups.com> <6f7cd771-16b7-4729-9536-2a7d1c28a9cd@2g2000hsn.googlegroups.com> <93b0d930-102a-4ac4-8b85-48e87d9d3df1@j33g2000pri.googlegroups.com> <48197575$1_1@glkas0286.greenlnk.net> NNTP-Posting-Host: 75.171.61.127 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1209686695 2800 127.0.0.1 (2 May 2008 00:04:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 2 May 2008 00:04:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p25g2000pri.googlegroups.com; posting-host=75.171.61.127; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21171 Date: 2008-05-01T17:04:53-07:00 List-Id: On May 1, 1:04=A0am, "Stuart" wrote: > "Adam Beneschan" wrote in message > > news:93b0d930-102a-4ac4-8b85-48e87d9d3df1@j33g2000pri.googlegroups.com...>= On Apr 30, 3:50 am, christoph.gr...@eurocopter.com wrote: > >> On 30 Apr., 12:47, christoph.gr...@eurocopter.com wrote: > > >> > Try Float'Valid (X), see RM 13.9.2 > > >> Ahem, I meant X'Valid for X of type Float > > > > > The problem here is that if you're dealing with NaN's on purpose, > > you're not really dealing with Ada, as far as I can tell, unless your > > purpose is to test for an uninitialized variable (in which case > > X'Valid makes sense). =A0Otherwise, though, NaN's and infinities are not= > > possible values of floating-point types, and therefore they can't be > > returned by operations that return floating-point values, even if > > Float'Machine_Overflows is False. =A0(There are certain passages in the > > RM that say a result is implementation-defined if the > > Machine_Overflows attribute is False; however, I do not think > > assigning a variable to an invalid value, as a NaN would be, is an > > allowed "implementation-defined" result. =A013.9.2(4-11) lists the ways > > that invalid data could be created, and the "result of a floating- > > point operation that cannot return a valid result" is not one of those > > listed. =A0Yes, I know that this is a NOTE and is not normative.) > > Would not 13.9.2(10) cover this: > =A0 =A0"disrupting an assignment due to the failure of a language-defined = check > (see 11.6)" > > Thus if a floating point operation creates a NaN, which would indicate an > ill-conditioned computation that should violate some language-defined chec= k, > the object (X) that was to receive the result would be considered invalid.= > > As noted elsewhere, 'valid encompasses more than NaNs - which may or may n= ot > suit the OPs purpose. Not sure. Apparently, the plotting example I'm translating from C needs to check for NaN when the underlying surface plot machinery is working. It seems odd that this heavy a responsibility should appear to the user in an example, but that's out of my control. I suppose 'valid would work since I doubt that other pathologies would arise. Jerry > > Regards > -- > Stuart