Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: How to chec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 17 of 35 Topic 5676 of 5827
Post > Topic >>

Re: How to check a Float for NaN

by Jerry <lanceboyle@[EMAIL PROTECTED] > May 1, 2008 at 04:57 PM

On May 1, 12:52=A0pm, Keith Thompson <ks...@[EMAIL PROTECTED]
> wrote:
> Adam Beneschan <a...@[EMAIL PROTECTED]
> writes:
> > On Apr 30, 4:23 pm, I wrote:
> >> On Apr 30, 1:33 pm, Jerry <lancebo...@[EMAIL PROTECTED]
> 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 im****t the C function isnan.
>
> >> Be careful with that, too. =A0On my (Pentium Linux) system, the man
pag=
e
> >> for "isnan" says it takes a "double", which I think means a 64-bit
> >> float.
>
> > Ha, ha, ha, the man page lied. =A0Apparently (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. =A0But since isnan is a macro, doing an
Im****t=

> > pragma on it is likely going to fail since "isnan" is not the name of
> > an actual routine in the library. =A0That'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). =A0It
> 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. =A0The earlier
> C90 standard doesn't provide any such floating-point classification
> macros or functions. =A0Some C90 implementations might provide a
> function, rather than macro, called "isnan"; perhaps that's what your
> system do***ents.
>
> You can't interface to a C macro from Ada (as far as I know), but you
> can easily write a wrapper function. =A0Assuming your C implementation
> provides the isnan() macro as specified by C99, you can do this:
>
> =A0 =A0 #include <math.h>
>
> =A0 =A0 int float_isnan =A0 =A0 =A0 (float x) =A0 =A0 =A0 { return
isnan(x=
); }
> =A0 =A0 int double_isnan =A0 =A0 =A0(double x) =A0 =A0 =A0{ return
isnan(x=
); }
> =A0 =A0 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...@[EMAIL PROTECTED]
>
> Nokia
> "We must do something. =A0This is something. =A0Therefore, we must do
this=
.."
> =A0 =A0 -- 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 do***ented in a book called Apple Numerics Manual with
unspecified author****p 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
 




 35 Posts in Topic:
How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-04-30 03:27:51 
Re: How to check a Float for NaN
christoph.grein@[EMAIL PR  2008-04-30 03:47:54 
Re: How to check a Float for NaN
christoph.grein@[EMAIL PR  2008-04-30 03:50:15 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-04-30 08:02:05 
Re: How to check a Float for NaN
"Randy Brukardt"  2008-04-30 18:29:14 
Re: How to check a Float for NaN
"Stuart" <st  2008-05-01 09:04:11 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-04-30 13:33:17 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-04-30 13:36:21 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-04-30 14:53:54 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-04-30 16:23:13 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-04-30 18:00:21 
Re: How to check a Float for NaN
Keith Thompson <kst-u@  2008-05-01 12:52:16 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-04-30 18:05:41 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-05-01 07:38:40 
Re: How to check a Float for NaN
"Stuart" <st  2008-05-01 18:14:09 
Re: How to check a Float for NaN
"Randy Brukardt"  2008-05-01 14:22:35 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-05-01 16:57:26 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-05-01 17:04:53 
Re: How to check a Float for NaN
Martin Krischik <krisc  2008-05-05 20:23:02 
Re: How to check a Float for NaN
anon@[EMAIL PROTECTED] (  2008-05-10 17:00:51 
Re: How to check a Float for NaN
Keith Thompson <kst-u@  2008-05-11 15:00:55 
Re: How to check a Float for NaN
anon@[EMAIL PROTECTED] (  2008-05-12 02:01:18 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-05-05 13:49:25 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-05-06 11:09:56 
Re: How to check a Float for NaN
"Wiljan Derks"   2008-05-06 20:45:47 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-05-06 15:18:39 
Re: How to check a Float for NaN
"Randy Brukardt"  2008-05-07 17:56:57 
Re: How to check a Float for NaN
Stephen Leake <Stephe.  2008-05-09 03:24:21 
Re: How to check a Float for NaN
"Randy Brukardt"  2008-05-07 17:56:57 
Re: How to check a Float for NaN
Adam Beneschan <adam@[  2008-05-07 16:20:55 
Re: How to check a Float for NaN
anon@[EMAIL PROTECTED] (  2008-05-09 19:49:50 
Re: How to check a Float for NaN
Jerry <lanceboyle@[EMA  2008-05-09 19:36:58 
Re: How to check a Float for NaN
anon@[EMAIL PROTECTED] (  2008-05-10 03:53:54 
Re: How to check a Float for NaN
Georg Bauhaus <see.rep  2008-05-10 10:05:33 
Re: How to check a Float for NaN
christoph.grein@[EMAIL PR  2008-05-09 23:24:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:07:04 CDT 2008.