fastfloat / fast_float

Fast and exact implementation of the C++ from_chars functions for number types: 4x to 10x faster than strtod, part of GCC 12, Chromium, Redis and WebKit/Safari
Apache License 2.0
1.54k stars 132 forks source link

Question regarding the generalization of this algorithm #250

Closed tgross35 closed 4 months ago

tgross35 commented 4 months ago

The first section of "Fast Number Parsing Without Fallback" mentions the following:

We have that w × 10−343 < 2−1074 for all w < 264.

This same comparison is also mentioned in section 9.2 of "Number Parsing at a Gigabyte per Second". This formula is relevant in the derivation of the smallest_power_of_ten constant, which must be specified in order to generalize the algorithm.

My question that is relevant for generalization: what is 64 in equation? I.e., what quantity does this number describe?

For context, please see discussion starting at: https://github.com/fastfloat/fast_float/pull/167#issuecomment-2195467913.

This is a general question about the algorithm implemented in this library, as described in the papers, that is applicable to understanding the enclosed code as well as expanding upon the algorithm. If this is not a suitable place to ask for clarification about this library's inspiration, I would appreciate a suggestion as to what a better channel is.

(the answer to this question may be helpful if C++23 bfloat16_t / float16_t / float128_t are added at any point, as in https://github.com/fastfloat/fast_float/issues/148).

lemire commented 4 months ago

From the second paragraph of the manuscript, we introduce $w$ as such an integer $w \in [1, 2^{64})$. The inequation $w < 2^{64}$ is just a restatement of this fact.

I am going to close this issue as I believe it is more of a discussion than an issue. I recommend taking questions to the discussion section of the GitHub repository.