diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-19 00:19:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-19 00:19:16 -0700 |
commit | 9c5fab4f4c3ef7cd39eececf6984378e4a48b56e (patch) | |
tree | 3c29ac5208941894d89808b7826fd4bf1f89a1e0 /arith.c | |
parent | bb30e8bc09ffaf5b7bf0ce7ecca17c55c8bf428d (diff) | |
download | txr-9c5fab4f4c3ef7cd39eececf6984378e4a48b56e.tar.gz txr-9c5fab4f4c3ef7cd39eececf6984378e4a48b56e.tar.bz2 txr-9c5fab4f4c3ef7cd39eececf6984378e4a48b56e.zip |
* arith.c (int_flo): Fix non-handling of negative values.
Diffstat (limited to 'arith.c')
-rw-r--r-- | arith.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1474,7 +1474,7 @@ val int_flo(val f) sprintf(text, "%.64g", d); - if (!isdigit(text[0])) + if (!isdigit(text[0]) && (text[0] != '-' || !isdigit(text[1]))) uw_throwf(error_s, lit("int-flo: cannot convert #<bad-float> to integer"), nao); @@ -1483,11 +1483,11 @@ val int_flo(val f) have_point = (strchr(text, '.') != 0); if (have_exp && have_point) - sscanf(text, "%127[0-9].%127[0-9]e%d", mint, mfrac, &exp); + sscanf(text, "%127[-0-9].%127[0-9]e%d", mint, mfrac, &exp); else if (have_exp) - sscanf(text, "%127[0-9]e%d", mint, &exp); + sscanf(text, "%127[-0-9]e%d", mint, &exp); else if (have_point) - sscanf(text, "%127[0-9].%127[0-9]", mint, mfrac); + sscanf(text, "%127[-0-9].%127[0-9]", mint, mfrac); else return int_str(string_utf8(text), nil); |