/* File name created by Gadow on . */ /* Last edited by Gadow on . */ /* Copyright (C) by IBM Corporation, 1990. */ /* private char ibmid[] = "Copyright(c) by IBM Corporation, 1990."; private char rcsHeader[] = "$Header: /mnt2/muller/m3/release/src/system/runtime/RCS/strtod.c,v 1.2 90/05/21 23:53:33 muller Exp $"; private char date[] = "$Date: 90/05/21 23:53:33 $"; private char revision[] = "$Revision: 1.2 $"; */ extern double atof( char *); double strtod(char *in, char **out) { char *s; s = in; while (*s == ' ') s++; /* AIX PS/2 allows it to have spaces at the beginning */ if (*s == '+' || *s == '-') s++; /* optional sign */ while (*s >= '0' && *s <= '9') s++; /* integer part */ if (*s == '.') s++; /* decimal point */ while (*s >= '0' && *s <= '9') s++; /* fractional part */ if (*s == 'e' || *s == 'E') { /* e and exponent */ s++; if (*s == '+' || *s == '-') s++; /* optional sign */ while (*s >= '0' && *s <= '9') s++; /* integer exponent */ } switch (*s) { case 'f': case 'F': case 'l': case 'L': s++; /* optional type suffix */ break; } *out = s; /* set out to the first character after the floating constant */ return( atof( in)); /* return the translated value of in */ } /* strtod */ #if defined(prog) char *x[] = { "12.34TestString", ".34TestString", "12e-2lTestString", "22e+344TestString", "+12.34TestString", "-12.34TestString"}; #define NUM 6 char *out; double _return; int main( char *argc, char **argv) { int i; for (i=0;i< NUM;i++) { _return = strtod( x[i], &out); printf( "%f, %s\n", _return, out); } } #endif /* by Brief description of the change and why it was made. $Log: strtod.c,v $ * Revision 1.2 90/05/21 23:53:33 muller * *** empty log message *** * */