Skip to content

Commit 84ca6a9

Browse files
robot-pigletneyrox
authored andcommitted
Update contrib/restricted/fast_float to 8.1.0
commit_hash:f7f58474cea1ab7af06958529ec19bb7e99d0235
1 parent 9a5354f commit 84ca6a9

File tree

8 files changed

+204
-62
lines changed

8 files changed

+204
-62
lines changed

contrib/restricted/fast_float/.yandex_meta/devtools.licenses.report

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BELONGS ya.make
3939
Match type : TAG
4040
Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
4141
Files with this license:
42-
README.md [543:543]
42+
README.md [605:605]
4343

4444
KEEP BSL-1.0 2c7a3fa82e66676005cd4ee2608fd7d2
4545
BELONGS ya.make
@@ -87,7 +87,7 @@ BELONGS ya.make
8787
Match type : REFERENCE
8888
Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0
8989
Files with this license:
90-
README.md [542:543]
90+
README.md [604:605]
9191

9292
KEEP Apache-2.0 AND MIT a76785199b4beee1ba8a8173f3d43241
9393
BELONGS ya.make
@@ -98,14 +98,14 @@ BELONGS ya.make
9898
Match type : NOTICE
9999
Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0
100100
Files with this license:
101-
README.md [537:552]
101+
README.md [599:614]
102102
Scancode info:
103103
Original SPDX id: MIT
104104
Score : 49.30
105105
Match type : NOTICE
106106
Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT
107107
Files with this license:
108-
README.md [537:552]
108+
README.md [599:614]
109109

110110
KEEP BSL-1.0 AND BSL-1.0 a8fd7a0ddc7793219e50dfdeb4742dfc
111111
BELONGS ya.make
@@ -117,14 +117,14 @@ BELONGS ya.make
117117
Match type : REFERENCE
118118
Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0
119119
Files with this license:
120-
README.md [544:544]
120+
README.md [606:606]
121121
Scancode info:
122122
Original SPDX id: BSL-1.0
123123
Score : 99.00
124124
Match type : REFERENCE
125125
Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0
126126
Files with this license:
127-
README.md [544:544]
127+
README.md [606:606]
128128

129129
KEEP Apache-2.0 c48d93dbb5419f7a8844879928a2fda7
130130
BELONGS ya.make
@@ -136,7 +136,7 @@ BELONGS ya.make
136136
Match type : NOTICE
137137
Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0
138138
Files with this license:
139-
README.md [537:537]
139+
README.md [599:599]
140140

141141
KEEP Apache-2.0 OR MIT OR BSL-1.0 dbfbb7aa50e4925e728f16d4a8adf7d9
142142
BELONGS ya.make
@@ -148,14 +148,14 @@ BELONGS ya.make
148148
Match type : INTRO
149149
Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
150150
Files with this license:
151-
README.md [542:542]
151+
README.md [604:604]
152152
Scancode info:
153153
Original SPDX id: Apache-2.0
154154
Score : 90.00
155155
Match type : TAG
156156
Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0
157157
Files with this license:
158-
README.md [542:542]
158+
README.md [604:604]
159159

160160
KEEP Apache-2.0 fb21a7d67961597593aefff800484f8d
161161
BELONGS ya.make
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
self: super: with self; rec {
22
name = "fast_float";
3-
version = "8.0.2";
3+
version = "8.1.0";
44

55
src = fetchFromGitHub {
66
owner = "fastfloat";
77
repo = "fast_float";
88
rev = "v${version}";
9-
hash = "sha256-lKEzRYKdpjsqixC9WBoILccqB2ZkUtPUzT4Q4+j0oac=";
9+
hash = "sha256-kTLmk+mxfdN/+vKdyohcaNSeoAkhJf3uesaBOz123ag=";
1010
};
1111
}

contrib/restricted/fast_float/README.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Example:
5757
```C++
5858
#include "fast_float/fast_float.h"
5959
#include <iostream>
60+
#include <string>
6061
6162
int main() {
6263
std::string input = "3.1416 xyz ";
@@ -68,6 +69,25 @@ int main() {
6869
}
6970
```
7071

72+
Though the C++17 standard has you do a comparison with `std::errc()` to check whether the conversion worked, you can avoid it by casting the result to a `bool` like so:
73+
74+
```cpp
75+
#include "fast_float/fast_float.h"
76+
#include <iostream>
77+
#include <string>
78+
79+
int main() {
80+
std::string input = "3.1416 xyz ";
81+
double result;
82+
if(auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result)) {
83+
std::cout << "parsed the number " << result << std::endl;
84+
return EXIT_SUCCESS;
85+
}
86+
std::cerr << "failed to parse " << result << std::endl;
87+
return EXIT_FAILURE;
88+
}
89+
```
90+
7191
You can parse delimited numbers:
7292

7393
```C++
@@ -357,13 +377,43 @@ int main() {
357377
}
358378
```
359379

380+
## Multiplication of an integer by a power of 10
381+
An integer `W` can be multiplied by a power of ten `10^Q` and
382+
converted to `double` with correctly rounded value
383+
(in "round to nearest, tie to even" fashion) using
384+
`fast_float::integer_times_pow10()`, e.g.:
385+
```C++
386+
const uint64_t W = 12345678901234567;
387+
const int Q = 23;
388+
const double result = fast_float::integer_times_pow10(W, Q);
389+
std::cout.precision(17);
390+
std::cout << W << " * 10^" << Q << " = " << result << " ("
391+
<< (result == 12345678901234567e23 ? "==" : "!=") << "expected)\n";
392+
```
393+
outputs
394+
```
395+
12345678901234567 * 10^23 = 1.2345678901234567e+39 (==expected)
396+
```
397+
`fast_float::integer_times_pow10()` gives the same result as
398+
using `fast_float::from_chars()` when parsing the string `"WeQ"`
399+
(in this example `"12345678901234567e23"`),
400+
except `fast_float::integer_times_pow10()` does not report out-of-range errors, and
401+
underflows to zero or overflows to infinity when the resulting value is
402+
out of range.
403+
404+
Overloads of `fast_float::integer_times_pow10()` are provided for
405+
signed and unsigned integer types: `int64_t`, `uint64_t`, etc.
406+
407+
360408
## Users and Related Work
361409

362410
The fast_float library is part of:
363411

364412
* GCC (as of version 12): the `from_chars` function in GCC relies on fast_float,
365413
* [Chromium](https://github.com/Chromium/Chromium), the engine behind Google
366414
Chrome, Microsoft Edge, and Opera,
415+
* Boost JSON, MySQL, etc.
416+
* Blender
367417
* [WebKit](https://github.com/WebKit/WebKit), the engine behind Safari (Apple's
368418
web browser),
369419
* [DuckDB](https://duckdb.org),
@@ -376,7 +426,10 @@ The fast_float library is part of:
376426
The fastfloat algorithm is part of the [LLVM standard
377427
libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
378428
There is a [derived implementation part of
379-
AdaCore](https://github.com/AdaCore/VSS).
429+
AdaCore](https://github.com/AdaCore/VSS). The [SerenityOS operating
430+
system](https://github.com/SerenityOS/serenity/commit/53b7f5e6a11e663c83df8030c3171c5945cb75ec)
431+
has a derived implementation that is inherited by the [Ladybird
432+
Browser](https://github.com/LadybirdBrowser/ladybird).
380433

381434
The fast_float library provides a performance similar to that of the
382435
[fast_double_parser](https://github.com/lemire/fast_double_parser) library but
@@ -385,6 +438,14 @@ API more in line with the expectations of C++ programmers. The
385438
fast_double_parser library is part of the [Microsoft LightGBM machine-learning
386439
framework](https://github.com/microsoft/LightGBM).
387440

441+
442+
443+
Packages
444+
------
445+
446+
[![Packaging status](https://repology.org/badge/vertical-allrepos/fastfloat.svg)](https://repology.org/project/fastfloat/versions)
447+
448+
388449
## References
389450

390451
* Daniel Lemire, [Number Parsing at a Gigabyte per
@@ -455,7 +516,7 @@ sufficiently recent version of CMake (3.11 or better at least):
455516
FetchContent_Declare(
456517
fast_float
457518
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
458-
GIT_TAG tags/v8.0.2
519+
GIT_TAG tags/v8.1.0
459520
GIT_SHALLOW TRUE)
460521
461522
FetchContent_MakeAvailable(fast_float)
@@ -471,7 +532,7 @@ You may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:
471532
CPMAddPackage(
472533
NAME fast_float
473534
GITHUB_REPOSITORY "fastfloat/fast_float"
474-
GIT_TAG v8.0.2)
535+
GIT_TAG v8.1.0)
475536
```
476537

477538
## Using as single header
@@ -483,7 +544,7 @@ if desired as described in the command line help.
483544

484545
You may directly download automatically generated single-header files:
485546

486-
<https://github.com/fastfloat/fast_float/releases/download/v8.0.2/fast_float.h>
547+
<https://github.com/fastfloat/fast_float/releases/download/v8.1.0/fast_float.h>
487548

488549
## Benchmarking
489550

@@ -522,6 +583,7 @@ cmake --build build
522583
manager](https://conan.io/center/recipes/fast_float).
523584
* It is part of the [brew package
524585
manager](https://formulae.brew.sh/formula/fast_float).
586+
* fast_float is available on [xmake](https://xmake.io) repository.
525587
* Some Linux distribution like Fedora include fast_float (e.g., as
526588
`fast_float-devel`).
527589

contrib/restricted/fast_float/include/fast_float/ascii_number.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ parse_number_string(UC const *p, UC const *pend,
441441
if (digit_count > 19) {
442442
answer.too_many_digits = true;
443443
// Let us start again, this time, avoiding overflows.
444-
// We don't need to check if is_integer, since we use the
444+
// We don't need to call if is_integer, since we use the
445445
// pre-tokenized spans from above.
446446
i = 0;
447447
p = answer.integer.ptr;
@@ -451,7 +451,7 @@ parse_number_string(UC const *p, UC const *pend,
451451
i = i * 10 + uint64_t(*p - UC('0'));
452452
++p;
453453
}
454-
if (i >= minimal_nineteen_digit_integer) { // We have a big integers
454+
if (i >= minimal_nineteen_digit_integer) { // We have a big integer
455455
exponent = end_of_integer_part - p + exp_number;
456456
} else { // We have a value with a fractional component.
457457
p = answer.fraction.ptr;

contrib/restricted/fast_float/include/fast_float/fast_float.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
4545
from_chars_advanced(UC const *first, UC const *last, T &value,
4646
parse_options_t<UC> options) noexcept;
4747

48+
/**
49+
* This function multiplies an integer number by a power of 10 and returns
50+
* the result as a double precision floating-point value that is correctly
51+
* rounded. The resulting floating-point value is the closest floating-point
52+
* value, using the "round to nearest, tie to even" convention for values that
53+
* would otherwise fall right in-between two values. That is, we provide exact
54+
* conversion according to the IEEE standard.
55+
*
56+
* On overflow infinity is returned, on underflow 0 is returned.
57+
*
58+
* The implementation does not throw and does not allocate memory (e.g., with
59+
* `new` or `malloc`).
60+
*/
61+
FASTFLOAT_CONSTEXPR20 inline double
62+
integer_times_pow10(uint64_t mantissa, int decimal_exponent) noexcept;
63+
FASTFLOAT_CONSTEXPR20 inline double
64+
integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept;
65+
4866
/**
4967
* from_chars for integer types.
5068
*/

contrib/restricted/fast_float/include/fast_float/float_common.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "constexpr_feature_detect.h"
1717

1818
#define FASTFLOAT_VERSION_MAJOR 8
19-
#define FASTFLOAT_VERSION_MINOR 0
20-
#define FASTFLOAT_VERSION_PATCH 2
19+
#define FASTFLOAT_VERSION_MINOR 1
20+
#define FASTFLOAT_VERSION_PATCH 0
2121

2222
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
2323
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
@@ -58,6 +58,11 @@ enum class chars_format : uint64_t {
5858
template <typename UC> struct from_chars_result_t {
5959
UC const *ptr;
6060
std::errc ec;
61+
62+
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2497r0.html
63+
constexpr explicit operator bool() const noexcept {
64+
return ec == std::errc();
65+
}
6166
};
6267

6368
using from_chars_result = from_chars_result_t<char>;
@@ -88,11 +93,12 @@ using parse_options = parse_options_t<char>;
8893
defined(__MINGW64__) || defined(__s390x__) || \
8994
(defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \
9095
defined(__PPC64LE__)) || \
91-
defined(__loongarch64))
96+
defined(__loongarch64) || (defined(__riscv) && __riscv_xlen == 64))
9297
#define FASTFLOAT_64BIT 1
9398
#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
9499
defined(__arm__) || defined(_M_ARM) || defined(__ppc__) || \
95-
defined(__MINGW32__) || defined(__EMSCRIPTEN__))
100+
defined(__MINGW32__) || defined(__EMSCRIPTEN__) || \
101+
(defined(__riscv) && __riscv_xlen == 32))
96102
#define FASTFLOAT_32BIT 1
97103
#else
98104
// Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow.
@@ -1126,7 +1132,12 @@ template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
11261132

11271133
template <typename UC>
11281134
fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) {
1129-
return int_luts<>::chdigit[static_cast<unsigned char>(c)];
1135+
// wchar_t and char can be signed, so we need to be careful.
1136+
using UnsignedUC = typename std::make_unsigned<UC>::type;
1137+
return int_luts<>::chdigit[static_cast<unsigned char>(
1138+
static_cast<UnsignedUC>(c) &
1139+
static_cast<UnsignedUC>(
1140+
-((static_cast<UnsignedUC>(c) & ~0xFFull) == 0)))];
11301141
}
11311142

11321143
fastfloat_really_inline constexpr size_t max_digits_u64(int base) {

0 commit comments

Comments
 (0)