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.182.103.199 with SMTP id fy7mr16659875obb.18.1401266436590; Wed, 28 May 2014 01:40:36 -0700 (PDT) X-Received: by 10.140.91.245 with SMTP id z108mr18145qgd.16.1401266436474; Wed, 28 May 2014 01:40:36 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!c1no18915357igq.0!news-out.google.com!qf4ni13600igc.0!nntp.google.com!c1no18915354igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 28 May 2014 01:40:36 -0700 (PDT) In-Reply-To: <840855a9-bda8-44b7-ab53-e157b4fc1d31@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=159.149.44.166; posting-account=uPViEgkAAACC04vaTYL5Kyk76brV1MA_ NNTP-Posting-Host: 159.149.44.166 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> <840855a9-bda8-44b7-ab53-e157b4fc1d31@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <518cd8ec-2b8a-4972-b120-d06642c78493@googlegroups.com> Subject: Re: How to check a Float for NaN From: Maurizio Tomasi Injection-Date: Wed, 28 May 2014 08:40:36 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:186677 Date: 2014-05-28T01:40:36-07:00 List-Id: > But you don't need NaN's built into the language in order to get that sor= t of functionality. In Ada (or C++ or any other language that supports ope= rator overloading), it's simple enough to define an "optional floating-poin= t" record type consisting of a float and a Boolean, where the Boolean indic= ates "missing data", and define operators that produce "missing data" if ei= ther operand is missing. So you could still write mostly the same code, ex= cept that converting to or from a float, or from a floating-point literal, = takes a little extra code. =20 Thanks a lot for your reply, I wrote my post with the hope of getting some = good advice about the best way to do such things in Ada. Yours is indeed a = smart idea! Funny that I have used C++ and operator overloading for years, yet I have n= ever realized that some sort of ad-hoc type (plus operator overloading) wou= ld be perfect here. Guess the reason is because I have used Python too much= : to get a reasonable speed in such calculations, you are forced to use fun= ctions like numpy.add (http://docs.scipy.org/doc/numpy/reference/generated/= numpy.add.html), which only accept basic numeric types. Cheers, Maurizio. (BTW, to answer Dmitry, speed *is* a concern for my calculations, which oft= en involve Fourier Transforms on the maps and heavy Monte Carlo simulations= . But fortunately functions like numpy.add are not that slow, as they are w= ritten in C/Fortran.)