xref: /openbsd/regress/lib/libm/cephes/testvectll.c (revision e5dd7070)
1 /*	$OpenBSD: testvectll.c,v 1.4 2013/08/02 22:19:33 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /* Test vectors for math functions.
20    See C9X section F.9.
21 
22    On some systems it may be necessary to modify the default exception
23    settings of the floating point arithmetic unit.  */
24 
25 #include <float.h>
26 
27 #if	LDBL_MANT_DIG == 113
28 #include <stdio.h>
29 #include <string.h>
30 int __isfinitel (long double);
31 
32 /* Some compilers will not accept these expressions.  */
33 
34 #define ZINF 1
35 #define ZMINF 2
36 #define ZNANL 3
37 #define ZPIL 4
38 #define ZPIO2L 4
39 
40 /*
41 extern long double INFINITYL, NANL, NEGZEROL;
42 */
43 long double INFINITYL, NANL, NEGZEROL;
44 long double MINFL;
45 extern long double PIL, PIO2L, PIO4L, MACHEPL;
46 long double MPIL;
47 long double MPIO2L;
48 long double MPIO4L;
49 long double THPIO4L = 2.35619449019234492884698L;
50 long double MTHPIO4L = -2.35619449019234492884698L;
51 long double SQRT2L = 1.414213562373095048802E0L;
52 long double SQRTHL = 7.071067811865475244008E-1L;
53 long double ZEROL = 0.0L;
54 long double HALFL = 0.5L;
55 long double MHALFL = -0.5L;
56 long double ONEL = 1.0L;
57 long double MONEL = -1.0L;
58 long double TWOL = 2.0L;
59 long double MTWOL = -2.0L;
60 long double THREEL = 3.0L;
61 long double MTHREEL = -3.0L;
62 
63 /* Functions of one variable.  */
64 long double logl (long double);
65 long double expl (long double);
66 long double atanl (long double);
67 long double sinl (long double);
68 long double cosl (long double);
69 long double tanl (long double);
70 long double acosl (long double);
71 long double asinl (long double);
72 long double acoshl (long double);
73 long double asinhl (long double);
74 long double atanhl (long double);
75 long double sinhl (long double);
76 long double coshl (long double);
77 long double tanhl (long double);
78 long double exp2l (long double);
79 long double expm1l (long double);
80 long double log10l (long double);
81 long double log1pl (long double);
82 long double log2l (long double);
83 long double fabsl (long double);
84 long double erfl (long double);
85 long double erfcl (long double);
86 long double tgammal (long double);
87 long double floorl (long double);
88 long double ceill (long double);
89 long double cbrtl (long double);
90 long double lgammal (long double);
91 
92 struct oneargument
93   {
94     char *name;			/* Name of the function. */
95     long double (*func) (long double);
96     long double *arg1;
97     long double *answer;
98     int thresh;			/* Error report threshold. */
99   };
100 
101 #if 0
102   {"sinl", sinl, 32767.L, 1.8750655394138942394239E-1L, 0},
103   {"cosl", cosl, 32767.L, 9.8226335176928229845654E-1L, 0},
104   {"tanl", tanl, 32767.L, 1.9089234430221485740826E-1L, 0},
105   {"sinl", sinl, 8388607.L, 9.9234509376961249835628E-1L, 0},
106   {"cosl", cosl, 8388607.L, -1.2349580912475928183718E-1L, 0},
107   {"tanl", tanl, 8388607.L, -8.0354556223613614748329E0L, 0},
108   {"sinl", sinl, 2147483647.L, -7.2491655514455639054829E-1L, 0},
109   {"cosl", cosl, 2147483647.L, -6.8883669187794383467976E-1L, 0},
110   {"tanl", tanl, 2147483647.L, 1.0523779637351339136698E0L, 0},
111   {"sinl", sinl, PIO4L, 7.0710678118654752440084E-1L, 0},
112   {"cosl", cosl, PIO2L, -2.50827880633416613471e-20L, 0},
113 #endif
114 
115 static struct oneargument test1[] =
116 {
117   {"atanl", atanl, &ONEL, &PIO4L, 0},
118   {"sinl", sinl, &PIO2L, &ONEL, 0},
119   {"cosl", cosl, &PIO4L, &SQRTHL, 0},
120   {"acosl", acosl, &NANL, &NANL, 0},
121   {"acosl", acosl, &ONEL, &ZEROL, 0},
122   {"acosl", acosl, &TWOL, &NANL, 0},
123   {"acosl", acosl, &MTWOL, &NANL, 0},
124   {"asinl", asinl, &NANL, &NANL, 0},
125   {"asinl", asinl, &ZEROL, &ZEROL, 0},
126   {"asinl", asinl, &NEGZEROL, &NEGZEROL, 0},
127   {"asinl", asinl, &TWOL, &NANL, 0},
128   {"asinl", asinl, &MTWOL, &NANL, 0},
129   {"atanl", atanl, &NANL, &NANL, 0},
130   {"atanl", atanl, &ZEROL, &ZEROL, 0},
131   {"atanl", atanl, &NEGZEROL, &NEGZEROL, 0},
132   {"atanl", atanl, &INFINITYL, &PIO2L, 0},
133   {"atanl", atanl, &MINFL, &MPIO2L, 0},
134   {"cosl", cosl, &NANL, &NANL, 0},
135   {"cosl", cosl, &ZEROL, &ONEL, 0},
136   {"cosl", cosl, &NEGZEROL, &ONEL, 0},
137   {"cosl", cosl, &INFINITYL, &NANL, 0},
138   {"cosl", cosl, &MINFL, &NANL, 0},
139   {"sinl", sinl, &NANL, &NANL, 0},
140   {"sinl", sinl, &NEGZEROL, &NEGZEROL, 0},
141   {"sinl", sinl, &ZEROL, &ZEROL, 0},
142   {"sinl", sinl, &INFINITYL, &NANL, 0},
143   {"sinl", sinl, &MINFL, &NANL, 0},
144   {"tanl", tanl, &NANL, &NANL, 0},
145   {"tanl", tanl, &ZEROL, &ZEROL, 0},
146   {"tanl", tanl, &NEGZEROL, &NEGZEROL, 0},
147   {"tanl", tanl, &INFINITYL, &NANL, 0},
148   {"tanl", tanl, &MINFL, &NANL, 0},
149   {"acoshl", acoshl, &NANL, &NANL, 0},
150   {"acoshl", acoshl, &ONEL, &ZEROL, 0},
151   {"acoshl", acoshl, &INFINITYL, &INFINITYL, 0},
152   {"acoshl", acoshl, &HALFL, &NANL, 0},
153   {"acoshl", acoshl, &MONEL, &NANL, 0},
154   {"asinhl", asinhl, &NANL, &NANL, 0},
155   {"asinhl", asinhl, &ZEROL, &ZEROL, 0},
156   {"asinhl", asinhl, &NEGZEROL, &NEGZEROL, 0},
157   {"asinhl", asinhl, &INFINITYL, &INFINITYL, 0},
158   {"asinhl", asinhl, &MINFL, &MINFL, 0},
159   {"atanhl", atanhl, &NANL, &NANL, 0},
160   {"atanhl", atanhl, &ZEROL, &ZEROL, 0},
161   {"atanhl", atanhl, &NEGZEROL, &NEGZEROL, 0},
162   {"atanhl", atanhl, &ONEL, &INFINITYL, 0},
163   {"atanhl", atanhl, &MONEL, &MINFL, 0},
164   {"atanhl", atanhl, &TWOL, &NANL, 0},
165   {"atanhl", atanhl, &MTWOL, &NANL, 0},
166   {"coshl", coshl, &NANL, &NANL, 0},
167   {"coshl", coshl, &ZEROL, &ONEL, 0},
168   {"coshl", coshl, &NEGZEROL, &ONEL, 0},
169   {"coshl", coshl, &INFINITYL, &INFINITYL, 0},
170   {"coshl", coshl, &MINFL, &INFINITYL, 0},
171   {"sinhl", sinhl, &NANL, &NANL, 0},
172   {"sinhl", sinhl, &ZEROL, &ZEROL, 0},
173   {"sinhl", sinhl, &NEGZEROL, &NEGZEROL, 0},
174   {"sinhl", sinhl, &INFINITYL, &INFINITYL, 0},
175   {"sinhl", sinhl, &MINFL, &MINFL, 0},
176   {"tanhl", tanhl, &NANL, &NANL, 0},
177   {"tanhl", tanhl, &ZEROL, &ZEROL, 0},
178   {"tanhl", tanhl, &NEGZEROL, &NEGZEROL, 0},
179   {"tanhl", tanhl, &INFINITYL, &ONEL, 0},
180   {"tanhl", tanhl, &MINFL, &MONEL, 0},
181   {"expl", expl, &NANL, &NANL, 0},
182   {"expl", expl, &ZEROL, &ONEL, 0},
183   {"expl", expl, &NEGZEROL, &ONEL, 0},
184   {"expl", expl, &INFINITYL, &INFINITYL, 0},
185   {"expl", expl, &MINFL, &ZEROL, 0},
186   {"exp2l", exp2l, &NANL, &NANL, 0},
187   {"exp2l", exp2l, &ZEROL, &ONEL, 0},
188   {"exp2l", exp2l, &NEGZEROL, &ONEL, 0},
189   {"exp2l", exp2l, &INFINITYL, &INFINITYL, 0},
190   {"exp2l", exp2l, &MINFL, &ZEROL, 0},
191   {"expm1l", expm1l, &NANL, &NANL, 0},
192   {"expm1l", expm1l, &ZEROL, &ZEROL, 0},
193   {"expm1l", expm1l, &NEGZEROL, &NEGZEROL, 0},
194   {"expm1l", expm1l, &INFINITYL, &INFINITYL, 0},
195   {"expm1l", expm1l, &MINFL, &MONEL, 0},
196   {"logl", logl, &NANL, &NANL, 0},
197   {"logl", logl, &ZEROL, &MINFL, 0},
198   {"logl", logl, &NEGZEROL, &MINFL, 0},
199   {"logl", logl, &ONEL, &ZEROL, 0},
200   {"logl", logl, &MONEL, &NANL, 0},
201   {"logl", logl, &INFINITYL, &INFINITYL, 0},
202   {"log10l", log10l, &NANL, &NANL, 0},
203   {"log10l", log10l, &ZEROL, &MINFL, 0},
204   {"log10l", log10l, &NEGZEROL, &MINFL, 0},
205   {"log10l", log10l, &ONEL, &ZEROL, 0},
206   {"log10l", log10l, &MONEL, &NANL, 0},
207   {"log10l", log10l, &INFINITYL, &INFINITYL, 0},
208   {"log1pl", log1pl, &NANL, &NANL, 0},
209   {"log1pl", log1pl, &ZEROL, &ZEROL, 0},
210   {"log1pl", log1pl, &NEGZEROL, &NEGZEROL, 0},
211   {"log1pl", log1pl, &MONEL, &MINFL, 0},
212   {"log1pl", log1pl, &MTWOL, &NANL, 0},
213   {"log1pl", log1pl, &INFINITYL, &INFINITYL, 0},
214   {"log2l", log2l, &NANL, &NANL, 0},
215   {"log2l", log2l, &ZEROL, &MINFL, 0},
216   {"log2l", log2l, &NEGZEROL, &MINFL, 0},
217   {"log2l", log2l, &MONEL, &NANL, 0},
218   {"log2l", log2l, &INFINITYL, &INFINITYL, 0},
219   /*  {"fabsl", fabsl, &NANL, &NANL, 0}, */
220   {"fabsl", fabsl, &ONEL, &ONEL, 0},
221   {"fabsl", fabsl, &MONEL, &ONEL, 0},
222   {"fabsl", fabsl, &ZEROL, &ZEROL, 0},
223   {"fabsl", fabsl, &NEGZEROL, &ZEROL, 0},
224   {"fabsl", fabsl, &INFINITYL, &INFINITYL, 0},
225   {"fabsl", fabsl, &MINFL, &INFINITYL, 0},
226   {"cbrtl", cbrtl, &NANL, &NANL, 0},
227   {"cbrtl", cbrtl, &ZEROL, &ZEROL, 0},
228   {"cbrtl", cbrtl, &NEGZEROL, &NEGZEROL, 0},
229   {"cbrtl", cbrtl, &INFINITYL, &INFINITYL, 0},
230   {"cbrtl", cbrtl, &MINFL, &MINFL, 0},
231   {"erfl", erfl, &NANL, &NANL, 0},
232   {"erfl", erfl, &ZEROL, &ZEROL, 0},
233   {"erfl", erfl, &NEGZEROL, &NEGZEROL, 0},
234   {"erfl", erfl, &INFINITYL, &ONEL, 0},
235   {"erfl", erfl, &MINFL, &MONEL, 0},
236   {"erfcl", erfcl, &NANL, &NANL, 0},
237   {"erfcl", erfcl, &INFINITYL, &ZEROL, 0},
238   {"erfcl", erfcl, &MINFL, &TWOL, 0},
239   {"tgammal", tgammal, &NANL, &NANL, 0},
240   {"tgammal", tgammal, &INFINITYL, &INFINITYL, 0},
241   {"tgammal", tgammal, &MONEL, &NANL, 0},
242   {"tgammal", tgammal, &ZEROL, &INFINITYL, 0},
243   {"tgammal", tgammal, &MINFL, &NANL, 0},
244   {"lgammal", lgammal, &NANL, &NANL, 0},
245   {"lgammal", lgammal, &INFINITYL, &INFINITYL, 0},
246   {"lgammal", lgammal, &MONEL, &INFINITYL, 0},
247   {"lgammal", lgammal, &ZEROL, &INFINITYL, 0},
248   {"lgammal", lgammal, &MINFL, &INFINITYL, 0},
249   {"ceill", ceill, &NANL, &NANL, 0},
250   {"ceill", ceill, &ZEROL, &ZEROL, 0},
251   {"ceill", ceill, &NEGZEROL, &NEGZEROL, 0},
252   {"ceill", ceill, &INFINITYL, &INFINITYL, 0},
253   {"ceill", ceill, &MINFL, &MINFL, 0},
254   {"floorl", floorl, &NANL, &NANL, 0},
255   {"floorl", floorl, &ZEROL, &ZEROL, 0},
256   {"floorl", floorl, &NEGZEROL, &NEGZEROL, 0},
257   {"floorl", floorl, &INFINITYL, &INFINITYL, 0},
258   {"floorl", floorl, &MINFL, &MINFL, 0},
259   {"null", NULL, &ZEROL, &ZEROL, 0},
260 };
261 
262 /* Functions of two variables.  */
263 long double atan2l (long double, long double);
264 long double powl (long double, long double);
265 
266 struct twoarguments
267   {
268     char *name;			/* Name of the function. */
269     long double (*func) (long double, long double);
270     long double *arg1;
271     long double *arg2;
272     long double *answer;
273     int thresh;
274   };
275 
276 static struct twoarguments test2[] =
277 {
278   {"atan2l", atan2l, &ZEROL, &ONEL, &ZEROL, 0},
279   {"atan2l", atan2l, &NEGZEROL, &ONEL,&NEGZEROL, 0},
280   {"atan2l", atan2l, &ZEROL, &ZEROL, &ZEROL, 0},
281   {"atan2l", atan2l, &NEGZEROL, &ZEROL, &NEGZEROL, 0},
282   {"atan2l", atan2l, &ZEROL, &MONEL, &PIL, 0},
283   {"atan2l", atan2l, &NEGZEROL, &MONEL, &MPIL, 0},
284   {"atan2l", atan2l, &ZEROL, &NEGZEROL, &PIL, 0},
285   {"atan2l", atan2l, &NEGZEROL, &NEGZEROL, &MPIL, 0},
286   {"atan2l", atan2l, &ONEL, &ZEROL, &PIO2L, 0},
287   {"atan2l", atan2l, &ONEL, &NEGZEROL, &PIO2L, 0},
288   {"atan2l", atan2l, &MONEL, &ZEROL, &MPIO2L, 0},
289   {"atan2l", atan2l, &MONEL, &NEGZEROL, &MPIO2L, 0},
290   {"atan2l", atan2l, &ONEL, &INFINITYL, &ZEROL, 0},
291   {"atan2l", atan2l, &MONEL, &INFINITYL, &NEGZEROL, 0},
292   {"atan2l", atan2l, &INFINITYL, &ONEL, &PIO2L, 0},
293   {"atan2l", atan2l, &INFINITYL, &MONEL, &PIO2L, 0},
294   {"atan2l", atan2l, &MINFL, &ONEL, &MPIO2L, 0},
295   {"atan2l", atan2l, &MINFL, &MONEL, &MPIO2L, 0},
296   {"atan2l", atan2l, &ONEL, &MINFL, &PIL, 0},
297   {"atan2l", atan2l, &MONEL, &MINFL, &MPIL, 0},
298   {"atan2l", atan2l, &INFINITYL, &INFINITYL, &PIO4L, 0},
299   {"atan2l", atan2l, &MINFL, &INFINITYL, &MPIO4L, 0},
300   {"atan2l", atan2l, &INFINITYL, &MINFL, &THPIO4L, 0},
301   {"atan2l", atan2l, &MINFL, &MINFL, &MTHPIO4L, 0},
302   {"atan2l", atan2l, &ONEL, &ONEL, &PIO4L, 0},
303   {"atan2l", atan2l, &NANL, &ONEL, &NANL, 0},
304   {"atan2l", atan2l, &ONEL, &NANL, &NANL, 0},
305   {"atan2l", atan2l, &NANL, &NANL, &NANL, 0},
306   {"powl", powl, &ONEL, &ZEROL, &ONEL, 0},
307   {"powl", powl, &ONEL, &NEGZEROL, &ONEL, 0},
308   {"powl", powl, &MONEL, &ZEROL, &ONEL, 0},
309   {"powl", powl, &MONEL, &NEGZEROL, &ONEL, 0},
310   {"powl", powl, &INFINITYL, &ZEROL, &ONEL, 0},
311   {"powl", powl, &INFINITYL, &NEGZEROL, &ONEL, 0},
312   {"powl", powl, &NANL, &ZEROL, &ONEL, 0},
313   {"powl", powl, &NANL, &NEGZEROL, &ONEL, 0},
314   {"powl", powl, &TWOL, &INFINITYL, &INFINITYL, 0},
315   {"powl", powl, &MTWOL, &INFINITYL, &INFINITYL, 0},
316   {"powl", powl, &HALFL, &INFINITYL, &ZEROL, 0},
317   {"powl", powl, &MHALFL, &INFINITYL, &ZEROL, 0},
318   {"powl", powl, &TWOL, &MINFL, &ZEROL, 0},
319   {"powl", powl, &MTWOL, &MINFL, &ZEROL, 0},
320   {"powl", powl, &HALFL, &MINFL, &INFINITYL, 0},
321   {"powl", powl, &MHALFL, &MINFL, &INFINITYL, 0},
322   {"powl", powl, &INFINITYL, &HALFL, &INFINITYL, 0},
323   {"powl", powl, &INFINITYL, &TWOL, &INFINITYL, 0},
324   {"powl", powl, &INFINITYL, &MHALFL, &ZEROL, 0},
325   {"powl", powl, &INFINITYL, &MTWOL, &ZEROL, 0},
326   {"powl", powl, &MINFL, &THREEL, &MINFL, 0},
327   {"powl", powl, &MINFL, &TWOL, &INFINITYL, 0},
328   {"powl", powl, &MINFL, &MTHREEL, &NEGZEROL, 0},
329   {"powl", powl, &MINFL, &MTWOL, &ZEROL, 0},
330   {"powl", powl, &NANL, &ONEL, &NANL, 0},
331   {"powl", powl, &ONEL, &NANL, &ONEL, 0},
332   {"powl", powl, &NANL, &NANL, &NANL, 0},
333   {"powl", powl, &ONEL, &INFINITYL, &ONEL, 0},
334   {"powl", powl, &MONEL, &INFINITYL, &ONEL, 0},
335   {"powl", powl, &ONEL, &MINFL, &ONEL, 0},
336   {"powl", powl, &MONEL, &MINFL, &ONEL, 0},
337   {"powl", powl, &MTWOL, &HALFL, &NANL, 0},
338   {"powl", powl, &ZEROL, &MTHREEL, &INFINITYL, 0},
339   {"powl", powl, &NEGZEROL, &MTHREEL, &MINFL, 0},
340   {"powl", powl, &ZEROL, &MHALFL, &INFINITYL, 0},
341   {"powl", powl, &NEGZEROL, &MHALFL, &INFINITYL, 0},
342   {"powl", powl, &ZEROL, &THREEL, &ZEROL, 0},
343   {"powl", powl, &NEGZEROL, &THREEL, &NEGZEROL, 0},
344   {"powl", powl, &ZEROL, &HALFL, &ZEROL, 0},
345   {"powl", powl, &NEGZEROL, &HALFL, &ZEROL, 0},
346   {"null", NULL, &ZEROL, &ZEROL, &ZEROL, 0},
347 };
348 
349 /* Integer functions of one variable.  */
350 
351 int __isnanl (long double);
352 int __signbitl (long double);
353 
354 struct intans
355   {
356     char *name;			/* Name of the function. */
357     int (*func) (long double);
358     long double *arg1;
359     int ianswer;
360   };
361 
362 static struct intans test3[] =
363 {
364   {"isfinitel", __isfinitel, &ZEROL, 1},
365   {"isfinitel", __isfinitel, &INFINITYL, 0},
366   {"isfinitel", __isfinitel, &MINFL, 0},
367   {"isnanl", __isnanl, &NANL, 1},
368   {"isnanl", __isnanl, &INFINITYL, 0},
369   {"isnanl", __isnanl, &ZEROL, 0},
370   {"isnanl", __isnanl, &NEGZEROL, 0},
371   {"signbitl", __signbitl, &NEGZEROL, 1},
372   {"signbitl", __signbitl, &MONEL, 1},
373   {"signbitl", __signbitl, &ZEROL, 0},
374   {"signbitl", __signbitl, &ONEL, 0},
375   {"signbitl", __signbitl, &MINFL, 1},
376   {"signbitl", __signbitl, &INFINITYL, 0},
377   {"null", NULL, &ZEROL, 0},
378 };
379 
380 static volatile long double x1;
381 static volatile long double x2;
382 static volatile long double y;
383 static volatile long double answer;
384 
385 /* Print bits of a long double.  */
386 static void pvec (char *str, long double x)
387 {
388   union
389   {
390     long double d;
391     unsigned int i[4];
392   } u;
393   int i;
394 
395   u.d = x;
396   printf ("%s ", str);
397   for (i = 0; i < 4; i++)
398     printf ("%08x ", u.i[i]);
399   printf ("\n");
400 }
401 
402 int
403 testvectll ()
404 {
405   int i, nerrors, k, ianswer, ntests;
406   long double (*fun1) (long double);
407   long double (*fun2) (long double, long double);
408   int (*fun3) (long double);
409   long double e;
410   union
411     {
412       long double d;
413       char c[16];
414     } u, v;
415 
416   INFINITYL = ONEL/ZEROL;
417   pvec ("Infinity = ", INFINITYL);
418   NANL = INFINITYL - INFINITYL;
419   pvec ("Nan = ", NANL);
420   NEGZEROL = -ZEROL;
421   pvec ("-0.0 = ", NEGZEROL);
422     /* This masks off fpu exceptions on i386.  */
423     /* setfpu(0x137f); */
424   nerrors = 0;
425   ntests = 0;
426   MINFL = -INFINITYL;
427   MPIL = -PIL;
428   MPIO2L = -PIO2L;
429   MPIO4L = -PIO4L;
430   i = 0;
431   for (;;)
432     {
433       fun1 = test1[i].func;
434       if (fun1 == NULL)
435 	break;
436       x1 = *(test1[i].arg1);
437       y = (*(fun1)) (x1);
438       answer = *(test1[i].answer);
439       if (test1[i].thresh == 0)
440 	{
441 	  v.d = answer;
442 	  u.d = y;
443 	  if (memcmp(u.c, v.c, 16) != 0)
444 	    {
445 	      /* O.K. if both are NaNs of some sort.  */
446 	      if (__isnanl(v.d) && __isnanl(u.d))
447 		goto nxttest1;
448 	      goto wrongone;
449 	    }
450 	  else
451 	    goto nxttest1;
452 	}
453       if (y != answer)
454 	{
455 	  e = y - answer;
456 	  if (answer != 0.0L)
457 	    e = e / answer;
458 	  if (e < 0)
459 	    e = -e;
460 	  if (e > test1[i].thresh * MACHEPL)
461 	    {
462 wrongone:
463 	      printf ("%s (%.20Le) = %.20Le\n    should be %.20Le\n",
464 		      test1[i].name, x1, y, answer);
465 	      nerrors += 1;
466 	    }
467 	}
468 nxttest1:
469       ntests += 1;
470       i += 1;
471     }
472 
473   i = 0;
474   for (;;)
475     {
476       fun2 = test2[i].func;
477       if (fun2 == NULL)
478 	break;
479       x1 = *(test2[i].arg1);
480       x2 = *(test2[i].arg2);
481       y = (*(fun2)) (x1, x2);
482       answer = *(test2[i].answer);
483       if (test2[i].thresh == 0)
484 	{
485 	  v.d = answer;
486 	  u.d = y;
487 	  if (memcmp(u.c, v.c, 16) != 0)
488 	    {
489 	      /* O.K. if both are NaNs of some sort.  */
490 	      if (__isnanl(v.d) && __isnanl(u.d))
491 		goto nxttest2;
492 	      goto wrongtwo;
493 	    }
494 	  else
495 	    goto nxttest2;
496 	}
497       if (y != answer)
498 	{
499 	  e = y - answer;
500 	  if (answer != 0.0L)
501 	    e = e / answer;
502 	  if (e < 0)
503 	    e = -e;
504 	  if (e > test2[i].thresh * MACHEPL)
505 	    {
506 wrongtwo:
507 	      printf ("%s (%.20Le, %.20Le) = %.20Le\n    should be %.20Le\n",
508 		      test2[i].name, x1, x2, y, answer);
509 	      nerrors += 1;
510 	    }
511 	}
512 nxttest2:
513       ntests += 1;
514       i += 1;
515     }
516 
517 
518   i = 0;
519   for (;;)
520     {
521       fun3 = test3[i].func;
522       if (fun3 == NULL)
523 	break;
524       x1 = *(test3[i].arg1);
525       k = (*(fun3)) (x1);
526       ianswer = test3[i].ianswer;
527       if (k != ianswer)
528 	{
529 	  printf ("%s (%.20Le) = %d\n    should be. %d\n",
530 		  test3[i].name, x1, k, ianswer);
531 	  nerrors += 1;
532 	}
533       ntests += 1;
534       i += 1;
535     }
536 
537   printf ("%d errors in %d tests\n", nerrors, ntests);
538   return (nerrors);
539 }
540 #endif	/* LDBL_MANT_DIG == 113 */
541