[...]
In fact John Kupyer was right : on my system FLOAT is a type-def for
long double.
In that case, don't use frexpf(): Use frexpl() instead, or
#include<tgmath.h> and use frexp().
Thanks. I've never used the tgmath library before - can you give me any
pointers where to download it? What are the advantages over the standard
math library?
"Type-generic math" was added to C in the C99 Standard, toward
the end of the Clinton Administration. If you're using a pre-C99
implementation you might not have it, in which case you should use
frexpl() explicitly.
The <tgmath.h> standard header provides magical macros that
inspect their argument types and figure out whether to call the
float, double, or long double math function. Using <tgmath.h>, you
can just write frexp(x) and the compiler will inspect `x' to
decide whether to use frexpf, frexp (the actual function taking
double), or frexpl.
Your situation is exactly the kind of thing that motivated
<tgmath.h> in the first place. It's easy enough to write a call
to sqrtf() for a float argument or sqrtl() for a long double,
but when the type is hidden behind a typedef it's not so clear
which function to apply. In your case the visible name of the
type was FLOAT, so we all directed you to the frexp() function,
which is appropriate for a float argument. With <tgmath.h>, the
compiler will figure this out for you, even if the visible type
name is REAL or SCALAR: The compiler knows whether these resolve
to float or double or long double, and uses the appropriate
function.
The underlying functions are in <math.h>, and you can call
them by their full names if you desire (or if you must, lacking
a C99 implementation).
The latest "C11" Standard introduces machinery to let user-
written functions do similar magic, but I haven't tried it yet.