24 for (i
= 1; i
< ac
; i
++)
26 if (strcmp(av
[i
],"-v")==0)
28 if (strcmp(av
[i
],"-nomath2") == 0)
30 if (strcmp(av
[i
],"-nostrin") == 0)
32 if (strcmp(av
[i
],"-nois") == 0)
34 if (strcmp(av
[i
],"-nomath") == 0)
36 if (strcmp(av
[i
],"-nocvt") == 0)
38 if (strcmp(av
[i
],"-noiee") == 0)
52 if (ieee
) test_ieee();
53 printf("Tested %d functions, %d errors detected\n", count
, inacc
);
58 static _CONST
char *iname
= "foo";
60 _DEFUN(newfunc
,(string
),
63 if (strcmp(iname
, string
))
65 printf("testing %s\n", string
);
92 int strtod_vector
= 0;
96 __ieee_double_shape_type
*a _AND
97 __ieee_double_shape_type
*b
)
100 if (a
->parts
.msw
> b
->parts
.msw
)
105 else if (a
->parts
.msw
== b
->parts
.msw
)
107 if (a
->parts
.lsw
> b
->parts
.lsw
)
117 /* Return the first bit different between two double numbers */
119 _DEFUN(mag_of_error
,(is
, shouldbe
),
123 __ieee_double_shape_type a
,b
;
127 unsigned long int __x
;
128 unsigned long int msw
, lsw
;
133 if (a
.parts
.msw
== b
.parts
.msw
134 && a
.parts
.lsw
== b
.parts
.lsw
) return 64;
137 /* Subtract the larger from the smaller number */
139 a_big
= bigger(&a
, &b
);
144 a
.parts
.msw
= b
.parts
.msw
;
148 a
.parts
.lsw
= b
.parts
.lsw
;
154 __x
= (a
.parts
.lsw
) - (b
.parts
.lsw
);
155 msw
= (a
.parts
.msw
) - (b
.parts
.msw
) - (__x
> (a
.parts
.lsw
));
161 /* Find out which bit the difference is in */
163 for (i
= 0; i
< 32; i
++)
165 if (((msw
) & mask
)!=0) return i
;
170 for (i
= 0; i
< 32; i
++)
173 if (((lsw
) & mask
)!=0) return i
+32;
186 _DEFUN(test_sok
,(is
, shouldbe
),
190 if (strcmp(is
,shouldbe
))
192 printf("%s:%d, inacurate answer: (%s should be %s)\n",
200 _DEFUN(test_iok
,(is
, shouldbe
),
205 printf("%s:%d, inacurate answer: (%08x should be %08x)\n",
214 /* Compare counted strings upto a certain length - useful to test single
215 prec float conversions against double results
218 _DEFUN(test_scok
,(is
, shouldbe
, count
),
223 if (strncmp(is
,shouldbe
, count
))
225 printf("%s:%d, inacurate answer: (%s should be %s)\n",
234 _DEFUN(test_eok
,(is
, shouldbe
),
239 printf("%s:%d, bad errno answer: (%d should be %d)\n",
248 _DEFUN(test_mok
,(value
, shouldbe
, okmag
),
253 __ieee_double_shape_type a
,b
;
254 int mag
= mag_of_error(value
, shouldbe
);
257 /* error in the first bit is ok if the numbers are both 0 */
258 if (value
== 0.0 && shouldbe
== 0.0)
267 printf("%s:%d, wrong answer: bit %d ",
271 printf("%08x%08x %08x%08x) ",
272 a
.parts
.msw
, a
.parts
.lsw
,
273 b
.parts
.msw
, b
.parts
.lsw
);
274 printf("(%g %g)\n", a
.value
, b
.value
);
289 printf("(%g)\n", f2
);