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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!reality.xs3.de!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to check a Float for NaN Date: Fri, 23 May 2014 09:38:58 +0200 Organization: cbb software GmbH Message-ID: <1vwho0j33rn0v.1bw5jk59v7f7z.dlg@40tude.net> References: <3132e38d-18bb-4890-9cec-31056ac6e3ba@x19g2000prg.googlegroups.com> <83ce619a-beef-447f-91ef-ff3dd68ff9df@googlegroups.com> <3tso4mcv80hk.8j7e1grtnha0$.dlg@40tude.net> <6c8f74c9-4b4e-47a0-90e0-efa1ecdd5e2e@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: QTaafVZuunHujkJPndFR7g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:186569 Date: 2014-05-23T09:38:58+02:00 List-Id: On Thu, 22 May 2014 16:33:50 -0700 (PDT), Adam Beneschan wrote: > On Thursday, May 22, 2014 9:31:12 AM UTC-7, Dmitry A. Kazakov wrote: > >>> No, I don't think so. 3.5.7(8) says "The set of values for a floating >>> point type is the (infinite) set of rational numbers." This excludes NaN >>> and infinities, which are not rational numbers (nor any kind of number). >> >> These are not values of Long_Float. I guess that values of Long_Float are >> "machine numbers" defined in the following sentence. > > I'm not sure why the RM defined the "set of values" to be an infinite set; > I'm sure that this made the rest of the semantics easier to specify in > some way, but I don't know what that is. The set of *machine numbers* for > a type is a subset of this set of values. I think that intermediate > computations can involve numbers that aren't machine numbers (if they're > performed using a type with greater precision, for example); I'm not sure. > In any case, though, it's clear that infinities and NaN aren't part of the > "set of values", and thus they can't be part of the set of machine numbers > which is a subset of the "set of values". Yes, but NaN is certainly a machine value of IEEE 754 hardware. My impression is that the text was written prior to wide spread of IEEE 754 hardware and was not reviewed since. >> Why doesn't it preclude NaN returned and accepted by arithmetic operations? >> Either 3.5.7 lies or the operations do. > > I think it *does* preclude NaN, unless I don't understand what you mean. > I guess you could say that the "operations lie", because if > Machine_Overflows is False, an operation on two values of a floating-point > type may have an invalid result. Yes, but an invalid result still may not be outside the set of type values! If NaN is not a type value, then an operation returning NaN is not of the type. It is a type error then, a compiler/language bug. After all, floating-point types are models, there is no reason why a model could not have ideals NaN, +/-Inf as proper values and thus arithmetic operations were defined in terms of this extended set of values. Which is what IEEE 754 actually is all about. The semantics of X'Value to exclude IEEE ideals could be easily defined in 13.9.2 as a special case. (X'Succ and X'Pred are already defined correctly as returning a machine number.) 3.5.7 could be slightly rewritten to convey that type values include equivalents of some real numbers (machine numbers) and, possibly, of some ideals (machine special values). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de