No subject

Fred Tydeman sun!uunet.UU.NET!ibmsupt!ibmpa!tydeman
Fri Jun 15 08:50:01 PDT 1990


test(s)  /* test case for "perfect" conversion */
char *s ;
 
{
double x,atof(),strtod();
int e ;
extern errno;
long unsigned * pl;
 
pl=(long unsigned *) &x;
errno=0;
x=atof(s);
e=errno;
printf("   atof x %g %8X %8X errno %d s %s\n",x,pl[0],pl[1],e,s);
errno=0;
x=strtod(s,0);
e=errno;
printf(" strtod x %g %8X %8X errno %d s %s\n",x,pl[0],pl[1],e,s);
errno=0;
(void) sscanf(s,"%lf",&x);
e=errno;
printf(" sscanf x %g %8X %8X errno %d s %s\n",x,pl[0],pl[1],e,s);
}
 
main()
{
test("1");
test("-.1e00000000000000000000000000000000000000000000000000000000001");
test("0");
test("-0.0");
test("1.e+126");
test("1.0e+126");
test("-100000000000000000000000000000000000000000000000000000000000000");
test("-100000000000000000000000000000000000000000000000000000000000000.0");
test("-0999999999999999999999999999999999999999999999999999999");
test("-999999999999999999999999999999999999999999999999999999.0");
test("-836856653383323110000000000000000000000000000000000000000000000000000000000000000000000000.0000");
test("1e4294967296");   /* exponent is 2 ** 32 to see if you use 32-bit ints */
test("INF");
test("-infinity");
test("NAN");
test("-NaN");
test("NaNQ");
test("-NaNS");
test("NaN(5)");
}                   /* end of "perfect" conversion test case */



More information about the Numeric-interest mailing list