[comp.lang.c] double precision FP problem in Turbo C's strtod

kaires@hubcap.clemson.edu (Robert G Kaires) (03/04/90)

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 <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

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);
   }
}