From 87ef6aeb02b75f71138a0b3a74db00e5a366efed Mon Sep 17 00:00:00 2001 From: Takeshi Watanabe Date: Tue, 17 Apr 2018 22:58:33 +0900 Subject: Fallback to float when caompiled binary with 64bit compiler. closes #3997. --- src/string.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index 469335bb9..8ebd11b6c 100644 --- a/src/string.c +++ b/src/string.c @@ -2167,8 +2167,13 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base, n *= base; n += c; if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) { - mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", - mrb_str_new(mrb, str, pend-str)); + if (base == 10) { + return mrb_float_value(mrb, mrb_str_to_dbl(mrb, mrb_str_new(mrb, str, len), badcheck)); + } + else { + mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", + mrb_str_new(mrb, str, pend-str)); + } } } val = (mrb_int)n; -- cgit v1.2.3