This is the mail archive of the
mailing list for the Java project.
Re: libjava configure question
Bryce McKinlay writes:
> Andrew Haley wrote:
> > > Yes, that's probably true. We'd have to make sure that calls to
> > > java::lang::Math::sin() etc. were replaced by sin() and we'd also have
> > > either to remove our own definitions of the functions or make them
> > > weak.
> > >
> > > All quite possible, but perhaps not top of the list.
> >I just tried, and I discovered that even without any optimizations
> >gcc/glibc fails dismally to meet even the relaxed java.lang.Math
> >accuracy requirement for trig functions. We should keep our own math
> >library, because it's better.
> Hmm, thats quite surprising. Are you sure this was using the real math
> library functions and not substituting FPU instructions? Do you have
> some test case that checks for conformance?
The first result comes from the standard library, the second from GMP,
calculated to high precision. The Java spec says that the answer must
be right +/- 1 ulp.
$ gcc trial.c -lmpfr -lgmp -lm
public class trial
static public void main (String argv)
main (int argc, char **argv)
printf ("%.16g\n", sin (pow (2.0, 90.0)));
mpfr_t x, y, z, result;
mpfr_init2 (x, 128);
mpfr_init2 (y, 128);
mpfr_init2 (z, 128);
mpfr_init2 (result, 128);
mpfr_set_si (x, 2, 0);
mpfr_set_si (y, 90, 0);
mpfr_pow (z, x, y, 0);
mpfr_sin (result, z, 0);
mpfr_out_str(stdout, 10, 0, result, 0);