mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
readfloat.c: we don't need long double for mruby; fix #6365
`mrb_read_float()` function does not raise ERANGE (unlike `strtod()`) so we don't need high precision double for calculation.
This commit is contained in:
+3
-3
@@ -10,7 +10,7 @@ mrb_read_float(const char *str, char **endp, double *fp)
|
||||
{
|
||||
const char *p = str;
|
||||
const char *a = p;
|
||||
long double res = 0.0, frac = 0.0, div = 1.0;
|
||||
double res = 0.0, frac = 0.0, div = 1.0;
|
||||
int sign = 1;
|
||||
int digits = 0;
|
||||
|
||||
@@ -66,7 +66,7 @@ mrb_read_float(const char *str, char **endp, double *fp)
|
||||
e = e * 10 + (*p - '0');
|
||||
p++;
|
||||
}
|
||||
res *= powl(10.0, sign * e);
|
||||
res *= pow(10.0, sign * e);
|
||||
a = p;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ mrb_read_float(const char *str, char **endp, double *fp)
|
||||
// mruby does not require those checks
|
||||
#if 0
|
||||
// Check for underflow after applying the exponent
|
||||
if (res != 0.0 && fabsl(res) < (long double)DBL_MIN) {
|
||||
if (res != 0.0 && fabs(res) < DBL_MIN) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user