From: Jerry <lanceboyle@qwest.net>
Subject: Re: How to check a Float for NaN
Date: Thu, 1 May 2008 16:57:26 -0700 (PDT)
Date: 2008-05-01T16:57:26-07:00 [thread overview]
Message-ID: <cf875faa-948f-487d-8005-1efb1aa84a7c@y22g2000prd.googlegroups.com> (raw)
In-Reply-To: 87ve1xztsf.fsf@kvetch.smov.org
On May 1, 12:52 pm, Keith Thompson <ks...@mib.org> wrote:
> Adam Beneschan <a...@irvine.com> writes:
> > On Apr 30, 4:23 pm, I wrote:
> >> On Apr 30, 1:33 pm, Jerry <lancebo...@qwest.net> wrote:
> >> > Thanks for the insight. From my point of view, not having access to
> >> > the all the IEEE-754 features is a nuisance. I'm not sure what I'm
> >> > going to do--probably try in import the C function isnan.
>
> >> Be careful with that, too. On my (Pentium Linux) system, the man page
> >> for "isnan" says it takes a "double", which I think means a 64-bit
> >> float.
>
> > Ha, ha, ha, the man page lied. Apparently (on my system) isnan is a C
> > macro (in <math.h>), which will call one of three routines depending
> > on the size of the float. But since isnan is a macro, doing an Import
> > pragma on it is likely going to fail since "isnan" is not the name of
> > an actual routine in the library. That's on my OS, though; who knows
> > how it works on yours.
>
> > Anyway, good luck and have fun getting this to work.
>
> The C99 C standard (which is not widely implemented, at least not
> completely) specifies that isnan() is a macro that can take an
> argument of any floating-point type (float, double, long double). It
> might typically be implemented by invoking one of three functions
> depending on the size of the argument, but the standard doesn't
> specify any particular method; it could be pure magic. The earlier
> C90 standard doesn't provide any such floating-point classification
> macros or functions. Some C90 implementations might provide a
> function, rather than macro, called "isnan"; perhaps that's what your
> system documents.
>
> You can't interface to a C macro from Ada (as far as I know), but you
> can easily write a wrapper function. Assuming your C implementation
> provides the isnan() macro as specified by C99, you can do this:
>
> #include <math.h>
>
> int float_isnan (float x) { return isnan(x); }
> int double_isnan (double x) { return isnan(x); }
> int long_double_isnan (long double x) { return isnan(x); }
>
> and then provide Ada interfaces to those C functions.
>
> It's a bit of a roundabout way to do it (providing three distinct
> function wrappers for a single macro that's probably a wrapper for
> three distinct underlying functions), but it should work.
>
> --
> Keith Thompson (The_Other_Keith) <ks...@mib.org>
> Nokia
> "We must do something. This is something. Therefore, we must do this."
> -- Antony Jay and Jonathan Lynn, "Yes Minister"
That looks doable.
As an aside, I remember the early Pascal compilers on Macintosh
(Apple's own and the much-missed THINK Pascal nee MacPascal) dealt
with all of the 754 spec (as far as I know, which isn't very far) and
was very well documented in a book called Apple Numerics Manual with
unspecified authorship but with a forward by Prof. Kahan of UC
Berkeley. MacPascal did 96-bit floating point when it ran without
hardware acceleration and fell back to 80 bits with a FPU.
Jerry
next prev parent reply other threads:[~2008-05-01 23:57 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 10:27 How to check a Float for NaN Jerry
2008-04-30 10:47 ` christoph.grein
2008-04-30 10:50 ` christoph.grein
2008-04-30 15:02 ` Adam Beneschan
2008-04-30 20:33 ` Jerry
2008-04-30 23:23 ` Adam Beneschan
2008-05-01 1:00 ` Adam Beneschan
2008-05-01 19:52 ` Keith Thompson
2008-05-01 23:57 ` Jerry [this message]
2008-04-30 23:29 ` Randy Brukardt
2008-05-01 8:04 ` Stuart
2008-05-01 14:38 ` Adam Beneschan
2008-05-01 17:14 ` Stuart
2008-05-01 19:22 ` Randy Brukardt
2008-05-02 0:04 ` Jerry
2008-04-30 20:36 ` Jerry
2008-04-30 21:53 ` Adam Beneschan
2008-05-01 1:05 ` Jerry
2014-05-22 7:27 ` jan.de.kruyf
2014-05-22 8:09 ` Dmitry A. Kazakov
2014-05-22 9:24 ` Simon Wright
2014-05-22 9:48 ` Dmitry A. Kazakov
2014-05-22 15:28 ` Adam Beneschan
2014-05-22 16:31 ` Dmitry A. Kazakov
2014-05-22 23:33 ` Adam Beneschan
2014-05-23 7:38 ` Dmitry A. Kazakov
2014-05-23 21:39 ` Randy Brukardt
2014-05-27 8:35 ` Dmitry A. Kazakov
2014-05-27 12:35 ` Maurizio Tomasi
2014-05-27 15:53 ` Adam Beneschan
2014-05-27 22:35 ` Randy Brukardt
2014-05-27 22:59 ` Jeffrey Carter
2014-05-28 7:32 ` Dmitry A. Kazakov
2014-05-28 8:40 ` Maurizio Tomasi
2008-05-05 18:23 ` Martin Krischik
2008-05-05 20:49 ` Adam Beneschan
2008-05-06 18:09 ` Jerry
2008-05-06 18:45 ` Wiljan Derks
2008-05-06 22:18 ` Adam Beneschan
2008-05-07 22:56 ` Randy Brukardt
2008-05-07 23:20 ` Adam Beneschan
2008-05-09 7:24 ` Stephen Leake
2008-05-07 22:56 ` Randy Brukardt
2008-05-10 17:00 ` anon
2008-05-11 22:00 ` Keith Thompson
2008-05-12 2:01 ` anon
2008-05-09 19:49 ` anon
2008-05-10 2:36 ` Jerry
2008-05-10 3:53 ` anon
2008-05-10 6:24 ` christoph.grein
2008-05-10 8:05 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox