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=-0.9 required=5.0 tests=BAYES_00,FROM_NUMERIC_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,772ddcb41cd06d5b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!news-peer-lilac.gradwell.net!not-for-mail From: "Stuart" Newsgroups: comp.lang.ada 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> Subject: Re: How to check a Float for NaN Date: Thu, 1 May 2008 09:04:11 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Message-ID: <48197575$1_1@glkas0286.greenlnk.net> X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: 20.133.0.1 X-Trace: 1209629058 news.gradwell.net 660 dnews/20.133.0.1:32727 X-Complaints-To: news-abuse@gradwell.net Xref: g2news1.google.com comp.lang.ada:21161 Date: 2008-05-01T09:04:11+01:00 List-Id: "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). Otherwise, 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. (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. 13.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. Yes, I know that this is a NOTE and is not normative.) Would not 13.9.2(10) cover this: "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 check, 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 not suit the OPs purpose. Regards -- Stuart