fixed parsef, exponent can now follow integer part

master
Tibor Bizjak 2023-07-17 12:44:19 +02:00
parent bcff42f74d
commit e6de3d1193
1 changed files with 18 additions and 20 deletions

View File

@ -188,27 +188,25 @@ char * parsef(char s[], double *x)
int sign = SIGN(s);
ATOI(s, *x);
#define X(sep) *s != sep &&
if (DEC_SEP 1) {
*x *= sign;
return s;
}
#undef X
s++;
/* fractional part */
int exp = 0;
ATOI(s, *x, exp--);
*x *= sign * pow(10, exp);
#define X(sep) *s != sep &&
if (EXP_SEP 1)
return s;
#undef X
/* fractional part */
#define X(sep) *s == sep ||
if (DEC_SEP 0) {
s++;
ATOI(s, *x, exp--);
*x *= pow(10, exp);
}
*x *= sign;
#undef X
/* exponent part */
#define X(sep) *s == sep ||
if (EXP_SEP 0) {
s++;
/* exponent */
sign = SIGN(s);
exp = 0;
ATOI(s, exp);
*x *= pow(10, sign * exp);
}
#undef X
return s;
}