another independent ATAN discovery (TAN really)

Zhishun Alex Liu uunet!Eng.Sun.COM!Alex.Liu
Tue Dec 6 23:54:55 PST 1994


This appears to be a FPTAN bug instead.  In the case Broadleyamath.ucdavis.edu
identified and posted to comp.arch.arithmetic, FPTAN loses more than 20 bits
out of a total of 53!

On a FDIV-challenged Pentium:
x               3FEB5BD3 6D18F68D (+8.549592142878325029542e-01)
Correct  tan(x) 3FF26582 AAAA765D (+1.149782816566037313422e+00)
Computed tan(x) 3FF26582 AA9E4599 (+1.149782816388642325833e+00)

On a 486:
x               3FEB5BD3 6D18F68D (+8.549592142878325029542e-01)
Correct  tan(x) 3FF26582 AAAA765D (+1.149782816566037313422e+00)
Computed tan(x) 3FF26582 AAAA765D (+1.149782816566037313422e+00)

#include <stdio.h>
#include <stdlib.h>
#define	ddump(str, x)	printf("%s %08.8X %08.8X (%+.21e)\n", str,\
	((int *)&x)[1], ((int *)&x)[0], x)

extern long double __kernel_tanl(long double);
/*
 *	fldt	4(%esp)
 *	fptan
 *	fstp	%st(0)
 *	ret
 */
void
main(void) {
	double x = 0.8549592142878325;
	long double ldx = (long double) x;
	long double ldz = __kernel_tanl(ldx);
	double dz = (double) ldz;
	double ref = 1.149782816566037313422e+00;

	ddump("x              ", x);
	ddump("Correct  tan(x)", ref);
	ddump("Computed tan(x)", dz);
	exit(0);
}



More information about the Numeric-interest mailing list