23 for (i
= 1; i
< ac
; i
++)
25 if (strcmp(av
[i
],"-v")==0)
27 if (strcmp(av
[i
],"-nomath2") == 0)
29 if (strcmp(av
[i
],"-nostrin") == 0)
31 if (strcmp(av
[i
],"-nois") == 0)
33 if (strcmp(av
[i
],"-nomath") == 0)
35 if (strcmp(av
[i
],"-nocvt") == 0)
37 if (strcmp(av
[i
],"-noiee") == 0)
51 if (ieee
) test_ieee();
52 printf("Tested %d functions, %d errors detected\n", count
, inacc
);
57 static const char *iname
= "foo";
59 newfunc (const char *string
)
61 if (strcmp(iname
, string
))
63 printf("testing %s\n", string
);
90 int strtod_vector
= 0;
93 bigger (__ieee_double_shape_type
*a
,
94 __ieee_double_shape_type
*b
)
97 if (a
->parts
.msw
> b
->parts
.msw
)
102 else if (a
->parts
.msw
== b
->parts
.msw
)
104 if (a
->parts
.lsw
> b
->parts
.lsw
)
114 /* Return the first bit different between two double numbers */
116 mag_of_error (double is
,
119 __ieee_double_shape_type a
,b
;
123 unsigned long int __x
;
124 unsigned long int msw
, lsw
;
129 if (a
.parts
.msw
== b
.parts
.msw
130 && a
.parts
.lsw
== b
.parts
.lsw
) return 64;
133 /* Subtract the larger from the smaller number */
135 a_big
= bigger(&a
, &b
);
140 a
.parts
.msw
= b
.parts
.msw
;
144 a
.parts
.lsw
= b
.parts
.lsw
;
150 __x
= (a
.parts
.lsw
) - (b
.parts
.lsw
);
151 msw
= (a
.parts
.msw
) - (b
.parts
.msw
) - (__x
> (a
.parts
.lsw
));
157 /* Find out which bit the difference is in */
159 for (i
= 0; i
< 32; i
++)
161 if (((msw
) & mask
)!=0) return i
;
166 for (i
= 0; i
< 32; i
++)
169 if (((lsw
) & mask
)!=0) return i
+32;
185 if (strcmp(is
,shouldbe
))
187 printf("%s:%d, inacurate answer: (%s should be %s)\n",
199 printf("%s:%d, inacurate answer: (%08x should be %08x)\n",
208 /* Compare counted strings upto a certain length - useful to test single
209 prec float conversions against double results
216 if (strncmp(is
,shouldbe
, count
))
218 printf("%s:%d, inacurate answer: (%s should be %s)\n",
231 printf("%s:%d, bad errno answer: (%d should be %d)\n",
240 test_mok (double value
,
244 __ieee_double_shape_type a
,b
;
245 int mag
= mag_of_error(value
, shouldbe
);
248 /* error in the first bit is ok if the numbers are both 0 */
249 if (value
== 0.0 && shouldbe
== 0.0)
258 printf("%s:%d, wrong answer: bit %d ",
262 printf("%08x%08x %08x%08x) ",
263 a
.parts
.msw
, a
.parts
.lsw
,
264 b
.parts
.msw
, b
.parts
.lsw
);
265 printf("(%g %g)\n", a
.value
, b
.value
);
280 printf("(%g)\n", f2
);