This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] I/O of large integer and real kinds


On Wed, Jun 08, 2005 at 10:55:11AM +0200, FX Coudert wrote:
> >The above looks correct because log10l is not currently in libm.
> >FreeBSD does not use glibc.  I'm guessing that __log10l is 
> >suppose to be a builtin function, but I haven't gone looking.
> 
> log10l is garanteed in C99, so I took it for granted. What is the 
> FreeBSD way to compute log10 of long doubles?
> 

FreeBSD's math.h shows that only a handful of the C99 long double
functions are currently implemented.  Unfortunately, log10l is
not one of those.  These are the implemented functions: ceill,
copysignl, fabsl, fdiml, floorl, fmal, fmaxl, fminl, frexpl, ilogbl,
ldexpl, llroundl, lroundl, nextafterl, nexttowardl, roundl, scalblnl,
scalbnl, and truncl.

For your use in the IO routines, we can probably hack together an approximate
log10l by using frexpl, but this would only solve the FreeBSD issue.

#include <math.h>
long double
log10l (long double x)
{
  long double f;
  int n;
  f = frexpl(x, &n);  /* For x > 0., we have 0.5 <= f < 1.  */
  f = n * 0.301029999566398119521L + (long double) log10 ((double) f);
  return f;
}

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]