Bugs in jnf(3) and jn(3)

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Dec 6 22:33:00 GMT 2010


The following two codes demonstrate bugs in 
I suspect all versions of jnf(3) and jn(3).

zeus:kargl[213] cc -o z u.c -lm && ./z
2 4.317548e-01
3 -inf
4 4.069027e-02
5 -inf
6 3.247664e-03
7 -inf
8 7.495602e-05
9 -inf
zeus:kargl[214] cc -o z t.c -lm && ./z
2.404820e+00 1.989337e-01 1.989989e-01
2.404820e+00 1.973139e-01 1.989990e-01
2.404821e+00 1.995556e-01 1.989990e-01
2.404821e+00 1.977899e-01 1.989991e-01
2.404821e+00 2.007952e-01 1.989991e-01
2.404821e+00 1.986288e-01 1.989991e-01
2.404822e+00 1.970318e-01 1.989992e-01
2.404822e+00 1.999776e-01 1.989992e-01
2.404822e+00 1.976307e-01 1.989993e-01
2.404822e+00 2.017480e-01 1.989993e-01
zeus:kargl[215] /lib/libc.so.6 
GNU C Library (EGLIBC) stable release version 2.10.1, by Roland McGrath et al.

See http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/144306
for details.


#include<stdio.h>
#include<math.h>

int
main(void)
{
   float x;
   x = 2.404820;
   do {
      x = nextafterf(x, 10.);
      printf("%e %e %e\n", x, jnf(3,x), jn(3,(double)x));
   } while(x < 2.404826);
   return (0);
}

#include <stdio.h>
#include <math.h>

int
main(void)
{
  int n;
  double z;
  z = 2.4048255576957729;
  for (n = 2; n < 10; n++)
    printf("%d %e\n", n, jn(n,z));
  return 0;
}

-- 
Steve



More information about the Libc-help mailing list