home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include "ffp.h"
-
- FFP FFPLARGE = 1.0e10, FFPSMALL = 1.0e-10;
-
- #ifdef FASTFLOAT
- FFP atoFFP(string)
- register char *string;
- {
- register char *s, *end;
- register FFP val;
- register int epart, fpart, fexp;
- int sign;
-
- s = string;
- while (*s == ' ') s++;
- sign = ((*s == '-') ? -1 : 1);
-
- val = (FFP)abs(atoi(string));
-
- end = string;
- while (*end == ' ') end++;
- while (*end && (*end != ' ')) end++;
-
- if (!(s = strchr(string,'e'))) s = strchr(string,'E');
- epart = ((s && s<end) ? atoi(s+1) : 0);
-
- s = strchr(string, '.');
- if (s && s<end) {
- for (++s, fpart=fexp=0; (*s <= '9') && (*s >= '0'); s++) {
- fexp--;
- fpart = fpart*10 + (*s - '0');
- }
- val += (FFP)(fpart * pow(10., (FFP)fexp));
- }
-
- return ((FFP)(val * sign * pow(10., (FFP)epart)));
- }
- #endif
-