+++ This bug was initially created as a clone of Bug #13658 +++ tan is inaccurate, see bug #13658 for a reference. Test program: #define _GNU_SOURCE #include <stdio.h> #include <math.h> int main (void) { volatile float xf = 1e22; float s1f, s2f; volatile double xd = 1e22; double s1d, s2d; volatile long double xl = 1e22; long double s1l, s2l; s1d = tan (xd); printf ("double: \n"); printf ("x = %.17g\n", xd); printf ("s1 = %.17g\n", s1d); s1f = tanf (xf); printf ("\nfloat: \n"); printf ("x = %.17g\n", xf); printf ("s1 = %.17g\n", s1f); s1l = tanl (xl); printf ("\nlong double: \n"); printf ("x = %.17Lg\n", xl); printf ("s1 = %.17Lg\n", s1l); return 0; } On x86-64: double: x = 1e+22 s1 = -1.6287782256068988 float: x = 9.9999997781963084e+21 s1 = -1.0810239315032959 long double: x = 1e+22 s1 = -0.52180662513577755 And on x86: double: x = 1e+22 s1 = -0.52180662513577758 float: x = 9.9999997781963084e+21 s1 = -0.29305437207221985 long double: x = 1e+22 s1 = -0.52180662513577755 The correct result of tan (1e22) is: s1 = -1.6287782256068988
Fixed by: commit 11b90b9f504df5b2da91ce3a06c1657d99e4a95f Author: Joseph Myers <joseph@codesourcery.com> Date: Fri Mar 16 20:05:04 2012 +0000 Fix tan, tanl for large inputs.