"0x10".to_f should be 0, not 16.0; fix #4924

This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-01-06 22:27:39 +09:00
parent c60bccaa94
commit 3e4e10ffb6
+1
View File
@@ -2505,6 +2505,7 @@ mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck)
if (pend - p > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
mrb_value x;
if (!badcheck) return 0.0;
x = mrb_str_len_to_inum(mrb, p, pend-p, 0, badcheck);
if (mrb_fixnum_p(x))
d = (double)mrb_fixnum(x);