Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!samsung!sol.ctr.columbia.edu!emory!hubcap!kaires From: kaires@hubcap.clemson.edu (Robert G Kaires) Newsgroups: comp.lang.c Subject: double precision FP problem in Turbo C's strtod() Keywords: strtod(), floating point precision, double precision Message-ID: <8225@hubcap.clemson.edu> Date: 4 Mar 90 04:00:47 GMT Organization: Clemson University, Clemson, SC Lines: 35 I am using Turbo C 2.0. Double precision floating numbers are supposed to have a range from 10e-308 to 10e+308. So why does the following short program yield zero when 10e-100 is entered for "string". It doesn't have a problem with 10e+100! Is this a bug? I also have the same problem if I use the atof() function. On a related question: does anyone have a list of known bugs in Turbo C 2.0 (and their fixes!). Thanks for any and all help. Bob Kaires 3/3/90 #include #include #include #include main() { char string[30]={""}; char *ptr; double ans; clrscr(); while(1) { gets(string); if (*string == 'q') break; ans=strtod(string,&ptr); if ( ( string+strlen(string) ) != ptr ) printf("format error\n"); else printf("You typed the number: %E\n",ans); } }