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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.185.1 with SMTP id cm1mr12515542icb.10.1401205980736; Tue, 27 May 2014 08:53:00 -0700 (PDT) X-Received: by 10.50.176.227 with SMTP id cl3mr662800igc.11.1401205980656; Tue, 27 May 2014 08:53:00 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!hl10no6332685igb.0!news-out.google.com!gi6ni15574igc.0!nntp.google.com!hl10no6332676igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 27 May 2014 08:53:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <840855a9-bda8-44b7-ab53-e157b4fc1d31@googlegroups.com> Subject: Re: How to check a Float for NaN From: Adam Beneschan Injection-Date: Tue, 27 May 2014 15:53:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:20069 Date: 2014-05-27T08:53:00-07:00 List-Id: On Tuesday, May 27, 2014 5:35:26 AM UTC-7, Maurizio Tomasi wrote: > > That is, I see no sensible reason for NaNs or infinities -- they're jus= t ways of deferring detection of bugs. I would have hoped that Ada's moved = beyond that, just like it has for integers.] >=20 >=20 >=20 > Being a scientist working with large chunks of data, I find NaNs useful i= n a number of situations. I work in a domain (observational cosmology) wher= e we need to deal with sky maps containing ~10^7 pixels (you can think of a= "map" as a 1D vector where pixels on the sky sphere are ordered according = to some rule). Not every sky direction can be sampled, because of a number = of problems (in the instrument, in the observational strategy, in the data = reduction pipeline, etc.) >=20 >=20 >=20 > Therefore, in my Python+NumPy codes I always mark such directions using "= quiet NaNs". If I have to combine two maps in order e.g. to take their aver= age, the usual rules for combining NaNs are be exactly what I want. Writing= in Ada what I actually write in Python: >=20 > for I :=3D 1 to N do > Average_Map(I) :=3D 0.5 * (Map1(I) + Map2(I)); > end loop; Well, that's actually half Pascal and half Ada, but we understand what you = mean. But you don't need NaN's built into the language in order to get that sort = of functionality. In Ada (or C++ or any other language that supports opera= tor overloading), it's simple enough to define an "optional floating-point"= record type consisting of a float and a Boolean, where the Boolean indicat= es "missing data", and define operators that produce "missing data" if eith= er operand is missing. So you could still write mostly the same code, exce= pt that converting to or from a float, or from a floating-point literal, ta= kes a little extra code. =20 -- Adam