mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
readfloat.c: keep one extra fraction digit (17 -> 18)
18 decimal digits still fit in uint64_t (max ~1.8e19), so we can hold one more digit of precision without overflow risk.
This commit is contained in:
+1
-1
@@ -144,7 +144,7 @@ mrb_read_float(const char *str, char **endp, double *fp)
|
||||
// Parse fractional part
|
||||
if (*p == '.') {
|
||||
p++;
|
||||
while (ISDIGIT(*p) && frac_digits < 17) { // Limit precision to avoid overflow
|
||||
while (ISDIGIT(*p) && frac_digits < 18) { // Limit precision to avoid overflow
|
||||
frac_part = frac_part * 10 + (*p - '0');
|
||||
frac_digits++;
|
||||
digits++;
|
||||
|
||||
Reference in New Issue
Block a user