Adam Beneschan <adam@[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. 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 Im****t
> 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) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


|