If you tightened the FASTFLOAT_ETC_POWER range from [-325, +308] to [-307, +288] then you could drop that whole if-check. You'd fail over to the fallback (i.e. strtod) in more cases, but such cases (less than 1e-307 or more than 1e+288, roughly speaking) are arguably rare (e.g. compared to 1e+80 atoms in the universe). On the flip side, you'd have to measure it, but fewer if-checks could lead to faster code for the (still-numerous) common cases.
I picked [-307, +288] because, if power is in that range and i is a non-zero uint64_t then i is roughly in the range [1, 1.85e+19], so (i * (10 ** power)) is in the range [1e-307, 1.85e+307], entirely within [DBL_MIN, DBL_MAX] = [2.23e–308, 1.80e+308].
Tightening the ranges also has the small benefit of shrinking the mantissa_64 and mantissa_128 tables.
include/fast_double_parser.h
says:and later, in the
compute_float_64
function:If you tightened the
FASTFLOAT_ETC_POWER
range from[-325, +308]
to[-307, +288]
then you could drop that whole if-check. You'd fail over to the fallback (i.e.strtod
) in more cases, but such cases (less than1e-307
or more than1e+288
, roughly speaking) are arguably rare (e.g. compared to1e+80
atoms in the universe). On the flip side, you'd have to measure it, but fewer if-checks could lead to faster code for the (still-numerous) common cases.I picked
[-307, +288]
because, ifpower
is in that range andi
is a non-zerouint64_t
theni
is roughly in the range[1, 1.85e+19]
, so(i * (10 ** power))
is in the range[1e-307, 1.85e+307]
, entirely within[DBL_MIN, DBL_MAX] = [2.23e–308, 1.80e+308]
.Tightening the ranges also has the small benefit of shrinking the
mantissa_64
andmantissa_128
tables.