widening whole # input to a double on read_float_tail (issue 33)

This commit is contained in:
Alex Shinn 2010-02-05 13:30:00 +09:00
parent e8030d7eb7
commit 4020a1c1f6

6
sexp.c
View file

@ -19,7 +19,7 @@ static struct sexp_huff_entry huff_table[] = {
static int sexp_initialized_p = 0; static int sexp_initialized_p = 0;
sexp sexp_read_float_tail(sexp ctx, sexp in, sexp_uint_t whole, int negp); sexp sexp_read_float_tail(sexp ctx, sexp in, double whole, int negp);
static char sexp_separators[] = { static char sexp_separators[] = {
/* 1 2 3 4 5 6 7 8 9 a b c d e f */ /* 1 2 3 4 5 6 7 8 9 a b c d e f */
@ -1304,7 +1304,7 @@ sexp sexp_read_symbol(sexp ctx, sexp in, int init, int internp) {
return res; return res;
} }
sexp sexp_read_float_tail(sexp ctx, sexp in, sexp_uint_t whole, int negp) { sexp sexp_read_float_tail(sexp ctx, sexp in, double whole, int negp) {
sexp exponent=SEXP_VOID; sexp exponent=SEXP_VOID;
double res=0.0, scale=0.1, e=0.0; double res=0.0, scale=0.1, e=0.0;
int c; int c;
@ -1323,7 +1323,7 @@ sexp sexp_read_float_tail(sexp ctx, sexp in, sexp_uint_t whole, int negp) {
} else { } else {
sexp_push_char(ctx, c, in); sexp_push_char(ctx, c, in);
} }
res = ((double)whole + res) * pow(10, e); res = (whole + res) * pow(10, e);
if (negp) res *= -1; if (negp) res *= -1;
if ((scale == 0.1) && (exponent != SEXP_VOID) && (res == round(res))) if ((scale == 0.1) && (exponent != SEXP_VOID) && (res == round(res)))
return sexp_make_fixnum(res); return sexp_make_fixnum(res);