diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
commit | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch) | |
tree | 506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/restricted/fast_float | |
parent | 2d37894b1b037cf24231090eda8589bbb44fb6fc (diff) | |
download | ydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz |
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/fast_float')
12 files changed, 337 insertions, 337 deletions
diff --git a/contrib/restricted/fast_float/AUTHORS b/contrib/restricted/fast_float/AUTHORS index 60c9425823..8baed3a829 100644 --- a/contrib/restricted/fast_float/AUTHORS +++ b/contrib/restricted/fast_float/AUTHORS @@ -1,2 +1,2 @@ -Daniel Lemire -João Paulo Magalhaes +Daniel Lemire +João Paulo Magalhaes diff --git a/contrib/restricted/fast_float/CONTRIBUTORS b/contrib/restricted/fast_float/CONTRIBUTORS index 58a037cc55..c5cf18a70e 100644 --- a/contrib/restricted/fast_float/CONTRIBUTORS +++ b/contrib/restricted/fast_float/CONTRIBUTORS @@ -1,6 +1,6 @@ -Eugene Golushkov -Maksim Kita -Marcin Wojdyr -Neal Richardson -Tim Paine -Fabio Pellacini +Eugene Golushkov +Maksim Kita +Marcin Wojdyr +Neal Richardson +Tim Paine +Fabio Pellacini diff --git a/contrib/restricted/fast_float/LICENSE-MIT b/contrib/restricted/fast_float/LICENSE-MIT index 2fb2a37ad7..44d6aa8fad 100644 --- a/contrib/restricted/fast_float/LICENSE-MIT +++ b/contrib/restricted/fast_float/LICENSE-MIT @@ -2,26 +2,26 @@ MIT License Copyright (c) 2021 The fast_float authors -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/contrib/restricted/fast_float/README.md b/contrib/restricted/fast_float/README.md index 1e1c06d0a3..5195c5c85d 100644 --- a/contrib/restricted/fast_float/README.md +++ b/contrib/restricted/fast_float/README.md @@ -1,16 +1,16 @@ -## fast_float number parsing library: 4x faster than strtod +## fast_float number parsing library: 4x faster than strtod /badge.svg) /badge.svg)    -[](https://github.com/fastfloat/fast_float/actions/workflows/vs16-ci.yml) +[](https://github.com/fastfloat/fast_float/actions/workflows/vs16-ci.yml) The fast_float library provides fast header-only implementations for the C++ from_chars functions for `float` and `double` types. These functions convert ASCII strings representing decimal values (e.g., `1.3e10`) into binary types. We provide exact rounding (including -round to even). In our experience, these `fast_float` functions many times faster than comparable number-parsing functions from existing C++ standard libraries. +round to even). In our experience, these `fast_float` functions many times faster than comparable number-parsing functions from existing C++ standard libraries. Specifically, `fast_float` provides the following two functions with a C++17-like syntax (the library itself only requires C++11): @@ -69,7 +69,7 @@ The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/char * The `from_chars` function does not skip leading white-space characters. * [A leading `+` sign](https://en.cppreference.com/w/cpp/utility/from_chars) is forbidden. * It is generally impossible to represent a decimal value exactly as binary floating-point number (`float` and `double` types). We seek the nearest value. We round to an even mantissa when we are in-between two binary floating-point numbers. - + Furthermore, we have the following restrictions: * We only support `float` and `double` types at this time. * We only support the decimal format: we do not support hexadecimal strings. @@ -79,61 +79,61 @@ We support Visual Studio, macOS, Linux, freeBSD. We support big and little endia -## Using commas as decimal separator - - -The C++ standard stipulate that `from_chars` has to be locale-independent. In -particular, the decimal separator has to be the period (`.`). However, -some users still want to use the `fast_float` library with in a locale-dependent -manner. Using a separate function called `from_chars_advanced`, we allow the users -to pass a `parse_options` instance which contains a custom decimal separator (e.g., -the comma). You may use it as follows. - -```C++ -#include "fast_float/fast_float.h" -#include <iostream> +## Using commas as decimal separator + + +The C++ standard stipulate that `from_chars` has to be locale-independent. In +particular, the decimal separator has to be the period (`.`). However, +some users still want to use the `fast_float` library with in a locale-dependent +manner. Using a separate function called `from_chars_advanced`, we allow the users +to pass a `parse_options` instance which contains a custom decimal separator (e.g., +the comma). You may use it as follows. + +```C++ +#include "fast_float/fast_float.h" +#include <iostream> + +int main() { + const std::string input = "3,1416 xyz "; + double result; + fast_float::parse_options options{fast_float::chars_format::general, ','}; + auto answer = fast_float::from_chars_advanced(input.data(), input.data()+input.size(), result, options); + if((answer.ec != std::errc()) || ((result != 3.1416))) { std::cerr << "parsing failure\n"; return EXIT_FAILURE; } + std::cout << "parsed the number " << result << std::endl; + return EXIT_SUCCESS; +} +``` + + +## Reference + +- Daniel Lemire, [Number Parsing at a Gigabyte per Second](https://arxiv.org/abs/2101.11408), Software: Pratice and Experience 51 (8), 2021. + +## Other programming languages + +- [There is an R binding](https://github.com/eddelbuettel/rcppfastfloat) called `rcppfastfloat`. +- [There is a Rust port of the fast_float library](https://github.com/aldanor/fast-float-rust/) called `fast-float-rust`. +- [There is a Java port of the fast_float library](https://github.com/wrandelshofer/FastDoubleParser) called `FastDoubleParser`. +- [There is a C# port of the fast_float library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`. + -int main() { - const std::string input = "3,1416 xyz "; - double result; - fast_float::parse_options options{fast_float::chars_format::general, ','}; - auto answer = fast_float::from_chars_advanced(input.data(), input.data()+input.size(), result, options); - if((answer.ec != std::errc()) || ((result != 3.1416))) { std::cerr << "parsing failure\n"; return EXIT_FAILURE; } - std::cout << "parsed the number " << result << std::endl; - return EXIT_SUCCESS; -} -``` - - -## Reference - -- Daniel Lemire, [Number Parsing at a Gigabyte per Second](https://arxiv.org/abs/2101.11408), Software: Pratice and Experience 51 (8), 2021. - -## Other programming languages - -- [There is an R binding](https://github.com/eddelbuettel/rcppfastfloat) called `rcppfastfloat`. -- [There is a Rust port of the fast_float library](https://github.com/aldanor/fast-float-rust/) called `fast-float-rust`. -- [There is a Java port of the fast_float library](https://github.com/wrandelshofer/FastDoubleParser) called `FastDoubleParser`. -- [There is a C# port of the fast_float library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`. - - ## Relation With Other Work The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba). -The fast_float library provides a performance similar to that of the [fast_double_parser](https://github.com/lemire/fast_double_parser) library but using an updated algorithm reworked from the ground up, and while offering an API more in line with the expectations of C++ programmers. The fast_double_parser library is part of the [Microsoft LightGBM machine-learning framework](https://github.com/microsoft/LightGBM). +The fast_float library provides a performance similar to that of the [fast_double_parser](https://github.com/lemire/fast_double_parser) library but using an updated algorithm reworked from the ground up, and while offering an API more in line with the expectations of C++ programmers. The fast_double_parser library is part of the [Microsoft LightGBM machine-learning framework](https://github.com/microsoft/LightGBM). ## Users -The fast_float library is used by [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied the number parsing speed by two or three times. It is also used by [Yandex ClickHouse](https://github.com/ClickHouse/ClickHouse) and by [Google Jsonnet](https://github.com/google/jsonnet). +The fast_float library is used by [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied the number parsing speed by two or three times. It is also used by [Yandex ClickHouse](https://github.com/ClickHouse/ClickHouse) and by [Google Jsonnet](https://github.com/google/jsonnet). ## How fast is it? It can parse random floating-point numbers at a speed of 1 GB/s on some systems. We find that it is often twice as fast as the best available competitor, and many times faster than many standard-library implementations. -<img src="http://lemire.me/blog/wp-content/uploads/2020/11/fastfloat_speed.png" width="400"> - +<img src="http://lemire.me/blog/wp-content/uploads/2020/11/fastfloat_speed.png" width="400"> + ``` $ ./build/benchmarks/benchmark # parsing random integers in the range [0,1) @@ -147,11 +147,11 @@ fastfloat : 1042.38 MB/s (+/- 9.9 %) 49.68 Mfl See https://github.com/lemire/simple_fastfloat_benchmark for our benchmarking code. - -## Video - -[](http://www.youtube.com/watch?v=AVXgvlMeIm4)<br /> - + +## Video + +[](http://www.youtube.com/watch?v=AVXgvlMeIm4)<br /> + ## Using as a CMake dependency This library is header-only by design. The CMake file provides the `fast_float` target @@ -171,7 +171,7 @@ Or you may want to retrieve the dependency automatically if you have a sufficien FetchContent_Declare( fast_float GIT_REPOSITORY https://github.com/lemire/fast_float.git - GIT_TAG tags/v1.1.2 + GIT_TAG tags/v1.1.2 GIT_SHALLOW TRUE) FetchContent_MakeAvailable(fast_float) @@ -179,19 +179,19 @@ target_link_libraries(myprogram PUBLIC fast_float) ``` -You should change the `GIT_TAG` line so that you recover the version you wish to use. +You should change the `GIT_TAG` line so that you recover the version you wish to use. -## Using as single header +## Using as single header -The script `script/amalgamate.py` may be used to generate a single header -version of the library if so desired. -Just run the script from the root directory of this repository. -You can customize the license type and output file if desired as described in -the command line help. +The script `script/amalgamate.py` may be used to generate a single header +version of the library if so desired. +Just run the script from the root directory of this repository. +You can customize the license type and output file if desired as described in +the command line help. -You may directly download automatically generated single-header files: +You may directly download automatically generated single-header files: -https://github.com/fastfloat/fast_float/releases/download/v1.1.2/fast_float.h +https://github.com/fastfloat/fast_float/releases/download/v1.1.2/fast_float.h ## Credit @@ -201,18 +201,18 @@ invaluable feedback. Rémy Oudompheng first implemented a fast path we use in th The library includes code adapted from Google Wuffs (written by Nigel Tao) which was originally published under the Apache 2.0 license. - -## License - -<sup> -Licensed under either of <a href="LICENSE-APACHE">Apache License, Version -2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option. -</sup> - -<br> - -<sub> -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in this repository by you, as defined in the Apache-2.0 license, -shall be dual licensed as above, without any additional terms or conditions. -</sub> + +## License + +<sup> +Licensed under either of <a href="LICENSE-APACHE">Apache License, Version +2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option. +</sup> + +<br> + +<sub> +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this repository by you, as defined in the Apache-2.0 license, +shall be dual licensed as above, without any additional terms or conditions. +</sub> diff --git a/contrib/restricted/fast_float/include/fast_float/ascii_number.h b/contrib/restricted/fast_float/include/fast_float/ascii_number.h index 3e6bb3e9ef..dbc25c46c3 100644 --- a/contrib/restricted/fast_float/include/fast_float/ascii_number.h +++ b/contrib/restricted/fast_float/include/fast_float/ascii_number.h @@ -14,35 +14,35 @@ namespace fast_float { // able to optimize it well. fastfloat_really_inline bool is_integer(char c) noexcept { return c >= '0' && c <= '9'; } -fastfloat_really_inline uint64_t byteswap(uint64_t val) { - return (val & 0xFF00000000000000) >> 56 - | (val & 0x00FF000000000000) >> 40 - | (val & 0x0000FF0000000000) >> 24 - | (val & 0x000000FF00000000) >> 8 - | (val & 0x00000000FF000000) << 8 - | (val & 0x0000000000FF0000) << 24 - | (val & 0x000000000000FF00) << 40 - | (val & 0x00000000000000FF) << 56; -} - -fastfloat_really_inline uint64_t read_u64(const char *chars) { - uint64_t val; - ::memcpy(&val, chars, sizeof(uint64_t)); -#if FASTFLOAT_IS_BIG_ENDIAN == 1 - // Need to read as-if the number was in little-endian order. - val = byteswap(val); -#endif - return val; -} - -fastfloat_really_inline void write_u64(uint8_t *chars, uint64_t val) { -#if FASTFLOAT_IS_BIG_ENDIAN == 1 - // Need to read as-if the number was in little-endian order. - val = byteswap(val); -#endif - ::memcpy(chars, &val, sizeof(uint64_t)); -} - +fastfloat_really_inline uint64_t byteswap(uint64_t val) { + return (val & 0xFF00000000000000) >> 56 + | (val & 0x00FF000000000000) >> 40 + | (val & 0x0000FF0000000000) >> 24 + | (val & 0x000000FF00000000) >> 8 + | (val & 0x00000000FF000000) << 8 + | (val & 0x0000000000FF0000) << 24 + | (val & 0x000000000000FF00) << 40 + | (val & 0x00000000000000FF) << 56; +} + +fastfloat_really_inline uint64_t read_u64(const char *chars) { + uint64_t val; + ::memcpy(&val, chars, sizeof(uint64_t)); +#if FASTFLOAT_IS_BIG_ENDIAN == 1 + // Need to read as-if the number was in little-endian order. + val = byteswap(val); +#endif + return val; +} + +fastfloat_really_inline void write_u64(uint8_t *chars, uint64_t val) { +#if FASTFLOAT_IS_BIG_ENDIAN == 1 + // Need to read as-if the number was in little-endian order. + val = byteswap(val); +#endif + ::memcpy(chars, &val, sizeof(uint64_t)); +} + // credit @aqrit fastfloat_really_inline uint32_t parse_eight_digits_unrolled(uint64_t val) { const uint64_t mask = 0x000000FF000000FF; @@ -55,17 +55,17 @@ fastfloat_really_inline uint32_t parse_eight_digits_unrolled(uint64_t val) { } fastfloat_really_inline uint32_t parse_eight_digits_unrolled(const char *chars) noexcept { - return parse_eight_digits_unrolled(read_u64(chars)); + return parse_eight_digits_unrolled(read_u64(chars)); } // credit @aqrit fastfloat_really_inline bool is_made_of_eight_digits_fast(uint64_t val) noexcept { return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) & - 0x8080808080808080)); + 0x8080808080808080)); } fastfloat_really_inline bool is_made_of_eight_digits_fast(const char *chars) noexcept { - return is_made_of_eight_digits_fast(read_u64(chars)); + return is_made_of_eight_digits_fast(read_u64(chars)); } typedef span<const char> byte_span; @@ -85,20 +85,20 @@ struct parsed_number_string { // Assuming that you use no more than 19 digits, this will // parse an ASCII string. fastfloat_really_inline -parsed_number_string parse_number_string(const char *p, const char *pend, parse_options options) noexcept { - const chars_format fmt = options.format; - const char decimal_point = options.decimal_point; - +parsed_number_string parse_number_string(const char *p, const char *pend, parse_options options) noexcept { + const chars_format fmt = options.format; + const char decimal_point = options.decimal_point; + parsed_number_string answer; answer.valid = false; - answer.too_many_digits = false; + answer.too_many_digits = false; answer.negative = (*p == '-'); - if (*p == '-') { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here + if (*p == '-') { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here ++p; if (p == pend) { return answer; } - if (!is_integer(*p) && (*p != decimal_point)) { // a sign must be followed by an integer or the dot + if (!is_integer(*p) && (*p != decimal_point)) { // a sign must be followed by an integer or the dot return answer; } } @@ -117,11 +117,11 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ uint64_t(*p - '0'); // might overflow, we will handle the overflow later ++p; } - const char *const end_of_integer_part = p; - int64_t digit_count = int64_t(end_of_integer_part - start_digits); + const char *const end_of_integer_part = p; + int64_t digit_count = int64_t(end_of_integer_part - start_digits); answer.integer = byte_span(start_digits, size_t(digit_count)); int64_t exponent = 0; - if ((p != pend) && (*p == decimal_point)) { + if ((p != pend) && (*p == decimal_point)) { ++p; const char* before = p; // can occur at most twice without overflowing, but let it occur more, since @@ -137,13 +137,13 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ } exponent = before - p; answer.fraction = byte_span(before, size_t(p - before)); - digit_count -= exponent; + digit_count -= exponent; } // we must have encountered at least one integer! - if (digit_count == 0) { + if (digit_count == 0) { return answer; } - int64_t exp_number = 0; // explicit exponential part + int64_t exp_number = 0; // explicit exponential part if ((fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) { const char * location_of_e = p; ++p; @@ -151,7 +151,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ if ((p != pend) && ('-' == *p)) { neg_exp = true; ++p; - } else if ((p != pend) && ('+' == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1) + } else if ((p != pend) && ('+' == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1) ++p; } if ((p == pend) || !is_integer(*p)) { @@ -169,8 +169,8 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ } ++p; } - if(neg_exp) { exp_number = - exp_number; } - exponent += exp_number; + if(neg_exp) { exp_number = - exp_number; } + exponent += exp_number; } } else { // If it scientific and not fixed, we have to bail out. @@ -182,43 +182,43 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ // If we frequently had to deal with long strings of digits, // we could extend our code by using a 128-bit integer instead // of a 64-bit integer. However, this is uncommon. - // - // We can deal with up to 19 digits. - if (digit_count > 19) { // this is uncommon + // + // We can deal with up to 19 digits. + if (digit_count > 19) { // this is uncommon // It is possible that the integer had an overflow. // We have to handle the case where we have 0.0000somenumber. - // We need to be mindful of the case where we only have zeroes... - // E.g., 0.000000000...000. + // We need to be mindful of the case where we only have zeroes... + // E.g., 0.000000000...000. const char *start = start_digits; - while ((start != pend) && (*start == '0' || *start == decimal_point)) { - if(*start == '0') { digit_count --; } + while ((start != pend) && (*start == '0' || *start == decimal_point)) { + if(*start == '0') { digit_count --; } start++; } - if (digit_count > 19) { + if (digit_count > 19) { answer.too_many_digits = true; - // Let us start again, this time, avoiding overflows. + // Let us start again, this time, avoiding overflows. // We don't need to check if is_integer, since we use the // pre-tokenized spans from above. - i = 0; + i = 0; p = answer.integer.ptr; const char* int_end = p + answer.integer.len(); - const uint64_t minimal_nineteen_digit_integer{1000000000000000000}; + const uint64_t minimal_nineteen_digit_integer{1000000000000000000}; while((i < minimal_nineteen_digit_integer) && (p != int_end)) { - i = i * 10 + uint64_t(*p - '0'); - ++p; - } - if (i >= minimal_nineteen_digit_integer) { // We have a big integers - exponent = end_of_integer_part - p + exp_number; - } else { // We have a value with a fractional component. + i = i * 10 + uint64_t(*p - '0'); + ++p; + } + if (i >= minimal_nineteen_digit_integer) { // We have a big integers + exponent = end_of_integer_part - p + exp_number; + } else { // We have a value with a fractional component. p = answer.fraction.ptr; const char* frac_end = p + answer.fraction.len(); while((i < minimal_nineteen_digit_integer) && (p != frac_end)) { - i = i * 10 + uint64_t(*p - '0'); - ++p; - } + i = i * 10 + uint64_t(*p - '0'); + ++p; + } exponent = answer.fraction.ptr - p + exp_number; - } - // We have now corrected both exponent and i, to a truncated value + } + // We have now corrected both exponent and i, to a truncated value } } answer.exponent = exponent; diff --git a/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h b/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h index 6da6c66a3a..adcc5bee0a 100644 --- a/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h +++ b/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h @@ -19,18 +19,18 @@ namespace fast_float { template <int bit_precision> fastfloat_really_inline value128 compute_product_approximation(int64_t q, uint64_t w) { - const int index = 2 * int(q - powers::smallest_power_of_five); + const int index = 2 * int(q - powers::smallest_power_of_five); // For small values of q, e.g., q in [0,27], the answer is always exact because // The line value128 firstproduct = full_multiplication(w, power_of_five_128[index]); // gives the exact answer. - value128 firstproduct = full_multiplication(w, powers::power_of_five_128[index]); + value128 firstproduct = full_multiplication(w, powers::power_of_five_128[index]); static_assert((bit_precision >= 0) && (bit_precision <= 64), " precision should be in (0,64]"); constexpr uint64_t precision_mask = (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision) : uint64_t(0xFFFFFFFFFFFFFFFF); if((firstproduct.high & precision_mask) == precision_mask) { // could further guard with (lower + w < lower) // regarding the second product, we only need secondproduct.high, but our expectation is that the compiler will optimize this extra work away if needed. - value128 secondproduct = full_multiplication(w, powers::power_of_five_128[index + 1]); + value128 secondproduct = full_multiplication(w, powers::power_of_five_128[index + 1]); firstproduct.low += secondproduct.high; if(secondproduct.high > firstproduct.low) { firstproduct.high++; @@ -39,7 +39,7 @@ value128 compute_product_approximation(int64_t q, uint64_t w) { return firstproduct; } -namespace detail { +namespace detail { /** * For q in (0,350), we have that * f = (((152170 + 65536) * q ) >> 16); @@ -58,7 +58,7 @@ namespace detail { constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept { return (((152170 + 65536) * q) >> 16) + 63; } -} // namespace detail +} // namespace detail // create an adjusted mantissa, biased by the invalid power2 // for significant digits already multiplied by 10 ** q. @@ -105,7 +105,7 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { answer.mantissa = 0; return answer; } - // At this point in time q is in [powers::smallest_power_of_five, powers::largest_power_of_five]. + // At this point in time q is in [powers::smallest_power_of_five, powers::largest_power_of_five]. // We want the most significant bit of i to be 1. Shift if needed. int lz = leading_zeroes(w); diff --git a/contrib/restricted/fast_float/include/fast_float/fast_float.h b/contrib/restricted/fast_float/include/fast_float/fast_float.h index 3c483803af..294d68e5c1 100644 --- a/contrib/restricted/fast_float/include/fast_float/fast_float.h +++ b/contrib/restricted/fast_float/include/fast_float/fast_float.h @@ -17,17 +17,17 @@ struct from_chars_result { std::errc ec; }; -struct parse_options { +struct parse_options { constexpr explicit parse_options(chars_format fmt = chars_format::general, - char dot = '.') - : format(fmt), decimal_point(dot) {} - - /** Which number formats are accepted */ - chars_format format; - /** The character used as decimal point */ - char decimal_point; -}; - + char dot = '.') + : format(fmt), decimal_point(dot) {} + + /** Which number formats are accepted */ + chars_format format; + /** The character used as decimal point */ + char decimal_point; +}; + /** * This function parses the character sequence [first,last) for a number. It parses floating-point numbers expecting * a locale-indepent format equivalent to what is used by std::strtod in the default ("C") locale. @@ -51,13 +51,13 @@ template<typename T> from_chars_result from_chars(const char *first, const char *last, T &value, chars_format fmt = chars_format::general) noexcept; -/** - * Like from_chars, but accepts an `options` argument to govern number parsing. - */ -template<typename T> -from_chars_result from_chars_advanced(const char *first, const char *last, - T &value, parse_options options) noexcept; - +/** + * Like from_chars, but accepts an `options` argument to govern number parsing. + */ +template<typename T> +from_chars_result from_chars_advanced(const char *first, const char *last, + T &value, parse_options options) noexcept; + } #include "parse_number.h" -#endif // FASTFLOAT_FAST_FLOAT_H +#endif // FASTFLOAT_FAST_FLOAT_H diff --git a/contrib/restricted/fast_float/include/fast_float/fast_table.h b/contrib/restricted/fast_float/include/fast_float/fast_table.h index 5766274ca4..945046c67d 100644 --- a/contrib/restricted/fast_float/include/fast_float/fast_table.h +++ b/contrib/restricted/fast_float/include/fast_float/fast_table.h @@ -29,18 +29,18 @@ namespace fast_float { * infinite in binary64 so we never need to worry about powers * of 5 greater than 308. */ -template <class unused = void> -struct powers_template { - -constexpr static int smallest_power_of_five = binary_format<double>::smallest_power_of_ten(); -constexpr static int largest_power_of_five = binary_format<double>::largest_power_of_ten(); -constexpr static int number_of_entries = 2 * (largest_power_of_five - smallest_power_of_five + 1); +template <class unused = void> +struct powers_template { + +constexpr static int smallest_power_of_five = binary_format<double>::smallest_power_of_ten(); +constexpr static int largest_power_of_five = binary_format<double>::largest_power_of_ten(); +constexpr static int number_of_entries = 2 * (largest_power_of_five - smallest_power_of_five + 1); // Powers of five from 5^-342 all the way to 5^308 rounded toward one. -static const uint64_t power_of_five_128[number_of_entries]; -}; - -template <class unused> -const uint64_t powers_template<unused>::power_of_five_128[number_of_entries] = { +static const uint64_t power_of_five_128[number_of_entries]; +}; + +template <class unused> +const uint64_t powers_template<unused>::power_of_five_128[number_of_entries] = { 0xeef453d6923bd65a,0x113faa2906a13b3f, 0x9558b4661b6565f8,0x4ac7ca59a424c507, 0xbaaee17fa23ebf76,0x5d79bcf00d2df649, @@ -692,7 +692,7 @@ const uint64_t powers_template<unused>::power_of_five_128[number_of_entries] = { 0xb6472e511c81471d,0xe0133fe4adf8e952, 0xe3d8f9e563a198e5,0x58180fddd97723a6, 0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,}; -using powers = powers_template<>; +using powers = powers_template<>; } diff --git a/contrib/restricted/fast_float/include/fast_float/float_common.h b/contrib/restricted/fast_float/include/fast_float/float_common.h index 9374cdffd4..8adc68e1c8 100644 --- a/contrib/restricted/fast_float/include/fast_float/float_common.h +++ b/contrib/restricted/fast_float/include/fast_float/float_common.h @@ -7,30 +7,30 @@ #include <cstring> #include <type_traits> -#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ +#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ || defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \ || defined(__MINGW64__) \ || defined(__s390x__) \ - || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) \ - || defined(__EMSCRIPTEN__)) + || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) \ + || defined(__EMSCRIPTEN__)) #define FASTFLOAT_64BIT -#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \ - || defined(__arm__) || defined(_M_ARM) \ - || defined(__MINGW32__)) -#define FASTFLOAT_32BIT +#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__arm__) || defined(_M_ARM) \ + || defined(__MINGW32__)) +#define FASTFLOAT_32BIT #else - // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow. - // We can never tell the register width, but the SIZE_MAX is a good approximation. - // UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max portability. - #if SIZE_MAX == 0xffff - #error Unknown platform (16-bit, unsupported) - #elif SIZE_MAX == 0xffffffff - #define FASTFLOAT_32BIT - #elif SIZE_MAX == 0xffffffffffffffff - #define FASTFLOAT_64BIT - #else - #error Unknown platform (not 32-bit, not 64-bit?) - #endif + // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow. + // We can never tell the register width, but the SIZE_MAX is a good approximation. + // UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max portability. + #if SIZE_MAX == 0xffff + #error Unknown platform (16-bit, unsupported) + #elif SIZE_MAX == 0xffffffff + #define FASTFLOAT_32BIT + #elif SIZE_MAX == 0xffffffffffffffff + #define FASTFLOAT_64BIT + #else + #error Unknown platform (not 32-bit, not 64-bit?) + #endif #endif #if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) @@ -46,8 +46,8 @@ #else #if defined(__APPLE__) || defined(__FreeBSD__) #include <machine/endian.h> -#elif defined(sun) || defined(__sun) -#include <sys/byteorder.h> +#elif defined(sun) || defined(__sun) +#include <sys/byteorder.h> #else #include <endian.h> #endif @@ -156,7 +156,7 @@ fastfloat_really_inline int leading_zeroes(uint64_t input_num) { #ifdef FASTFLOAT_32BIT // slow emulation routine for 32-bit -fastfloat_really_inline uint64_t emulu(uint32_t x, uint32_t y) { +fastfloat_really_inline uint64_t emulu(uint32_t x, uint32_t y) { return x * (uint64_t)y; } @@ -164,12 +164,12 @@ fastfloat_really_inline uint64_t emulu(uint32_t x, uint32_t y) { #if !defined(__MINGW64__) fastfloat_really_inline uint64_t _umul128(uint64_t ab, uint64_t cd, uint64_t *hi) { - uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd); - uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd); - uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32)); + uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd); + uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd); + uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32)); uint64_t adbc_carry = !!(adbc < ad); uint64_t lo = bd + (adbc << 32); - *hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) + + *hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) + (adbc_carry << 32) + !!(lo < bd); return lo; } @@ -186,7 +186,7 @@ fastfloat_really_inline value128 full_multiplication(uint64_t a, // ARM64 has native support for 64-bit multiplications, no need to emulate answer.high = __umulh(a, b); answer.low = a * b; -#elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__)) +#elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__)) answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64 #elif defined(FASTFLOAT_64BIT) __uint128_t r = ((__uint128_t)a) * b; @@ -205,9 +205,9 @@ struct adjusted_mantissa { bool operator==(const adjusted_mantissa &o) const { return mantissa == o.mantissa && power2 == o.power2; } - bool operator!=(const adjusted_mantissa &o) const { - return mantissa != o.mantissa || power2 != o.power2; - } + bool operator!=(const adjusted_mantissa &o) const { + return mantissa != o.mantissa || power2 != o.power2; + } }; // Bias so we can get the real exponent with an invalid adjusted_mantissa. @@ -222,72 +222,72 @@ constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, template <typename T> struct binary_format { using equiv_uint = typename std::conditional<sizeof(T) == 4, uint32_t, uint64_t>::type; - static inline constexpr int mantissa_explicit_bits(); - static inline constexpr int minimum_exponent(); - static inline constexpr int infinite_power(); - static inline constexpr int sign_index(); - static inline constexpr int min_exponent_fast_path(); - static inline constexpr int max_exponent_fast_path(); - static inline constexpr int max_exponent_round_to_even(); - static inline constexpr int min_exponent_round_to_even(); - static inline constexpr uint64_t max_mantissa_fast_path(); - static inline constexpr int largest_power_of_ten(); - static inline constexpr int smallest_power_of_ten(); - static inline constexpr T exact_power_of_ten(int64_t power); + static inline constexpr int mantissa_explicit_bits(); + static inline constexpr int minimum_exponent(); + static inline constexpr int infinite_power(); + static inline constexpr int sign_index(); + static inline constexpr int min_exponent_fast_path(); + static inline constexpr int max_exponent_fast_path(); + static inline constexpr int max_exponent_round_to_even(); + static inline constexpr int min_exponent_round_to_even(); + static inline constexpr uint64_t max_mantissa_fast_path(); + static inline constexpr int largest_power_of_ten(); + static inline constexpr int smallest_power_of_ten(); + static inline constexpr T exact_power_of_ten(int64_t power); static inline constexpr size_t max_digits(); static inline constexpr equiv_uint exponent_mask(); static inline constexpr equiv_uint mantissa_mask(); static inline constexpr equiv_uint hidden_bit_mask(); }; -template <> inline constexpr int binary_format<double>::mantissa_explicit_bits() { +template <> inline constexpr int binary_format<double>::mantissa_explicit_bits() { return 52; } -template <> inline constexpr int binary_format<float>::mantissa_explicit_bits() { +template <> inline constexpr int binary_format<float>::mantissa_explicit_bits() { return 23; } -template <> inline constexpr int binary_format<double>::max_exponent_round_to_even() { +template <> inline constexpr int binary_format<double>::max_exponent_round_to_even() { return 23; } -template <> inline constexpr int binary_format<float>::max_exponent_round_to_even() { +template <> inline constexpr int binary_format<float>::max_exponent_round_to_even() { return 10; } -template <> inline constexpr int binary_format<double>::min_exponent_round_to_even() { +template <> inline constexpr int binary_format<double>::min_exponent_round_to_even() { return -4; } -template <> inline constexpr int binary_format<float>::min_exponent_round_to_even() { +template <> inline constexpr int binary_format<float>::min_exponent_round_to_even() { return -17; } -template <> inline constexpr int binary_format<double>::minimum_exponent() { +template <> inline constexpr int binary_format<double>::minimum_exponent() { return -1023; } -template <> inline constexpr int binary_format<float>::minimum_exponent() { +template <> inline constexpr int binary_format<float>::minimum_exponent() { return -127; } -template <> inline constexpr int binary_format<double>::infinite_power() { +template <> inline constexpr int binary_format<double>::infinite_power() { return 0x7FF; } -template <> inline constexpr int binary_format<float>::infinite_power() { +template <> inline constexpr int binary_format<float>::infinite_power() { return 0xFF; } -template <> inline constexpr int binary_format<double>::sign_index() { return 63; } -template <> inline constexpr int binary_format<float>::sign_index() { return 31; } +template <> inline constexpr int binary_format<double>::sign_index() { return 63; } +template <> inline constexpr int binary_format<float>::sign_index() { return 31; } -template <> inline constexpr int binary_format<double>::min_exponent_fast_path() { +template <> inline constexpr int binary_format<double>::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else return -22; #endif } -template <> inline constexpr int binary_format<float>::min_exponent_fast_path() { +template <> inline constexpr int binary_format<float>::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else @@ -295,46 +295,46 @@ template <> inline constexpr int binary_format<float>::min_exponent_fast_path() #endif } -template <> inline constexpr int binary_format<double>::max_exponent_fast_path() { +template <> inline constexpr int binary_format<double>::max_exponent_fast_path() { return 22; } -template <> inline constexpr int binary_format<float>::max_exponent_fast_path() { +template <> inline constexpr int binary_format<float>::max_exponent_fast_path() { return 10; } -template <> inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } -template <> inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } template <> -inline constexpr double binary_format<double>::exact_power_of_ten(int64_t power) { +inline constexpr double binary_format<double>::exact_power_of_ten(int64_t power) { return powers_of_ten_double[power]; } template <> -inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) { +inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) { return powers_of_ten_float[power]; } template <> -inline constexpr int binary_format<double>::largest_power_of_ten() { +inline constexpr int binary_format<double>::largest_power_of_ten() { return 308; } template <> -inline constexpr int binary_format<float>::largest_power_of_ten() { +inline constexpr int binary_format<float>::largest_power_of_ten() { return 38; } template <> -inline constexpr int binary_format<double>::smallest_power_of_ten() { +inline constexpr int binary_format<double>::smallest_power_of_ten() { return -342; } template <> -inline constexpr int binary_format<float>::smallest_power_of_ten() { +inline constexpr int binary_format<float>::smallest_power_of_ten() { return -65; } @@ -387,7 +387,7 @@ fastfloat_really_inline void to_float(bool negative, adjusted_mantissa am, T &va #else // For little-endian systems: ::memcpy(&value, &word, sizeof(T)); -#endif +#endif } } // namespace fast_float diff --git a/contrib/restricted/fast_float/include/fast_float/parse_number.h b/contrib/restricted/fast_float/include/fast_float/parse_number.h index 62ae3b039e..2215e2915c 100644 --- a/contrib/restricted/fast_float/include/fast_float/parse_number.h +++ b/contrib/restricted/fast_float/include/fast_float/parse_number.h @@ -13,7 +13,7 @@ namespace fast_float { -namespace detail { +namespace detail { /** * Special case +inf, -inf, nan, infinity, -infinity. * The case comparisons could be made much faster given that we know that the @@ -22,37 +22,37 @@ namespace detail { template <typename T> from_chars_result parse_infnan(const char *first, const char *last, T &value) noexcept { from_chars_result answer; - answer.ptr = first; + answer.ptr = first; answer.ec = std::errc(); // be optimistic - bool minusSign = false; - if (*first == '-') { // assume first < last, so dereference without checks; C++17 20.19.3.(7.1) explicitly forbids '+' here - minusSign = true; - ++first; - } + bool minusSign = false; + if (*first == '-') { // assume first < last, so dereference without checks; C++17 20.19.3.(7.1) explicitly forbids '+' here + minusSign = true; + ++first; + } if (last - first >= 3) { if (fastfloat_strncasecmp(first, "nan", 3)) { - answer.ptr = (first += 3); - value = minusSign ? -std::numeric_limits<T>::quiet_NaN() : std::numeric_limits<T>::quiet_NaN(); - // Check for possible nan(n-char-seq-opt), C++17 20.19.3.7, C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan). - if(first != last && *first == '(') { - for(const char* ptr = first + 1; ptr != last; ++ptr) { - if (*ptr == ')') { - answer.ptr = ptr + 1; // valid nan(n-char-seq-opt) - break; - } - else if(!(('a' <= *ptr && *ptr <= 'z') || ('A' <= *ptr && *ptr <= 'Z') || ('0' <= *ptr && *ptr <= '9') || *ptr == '_')) - break; // forbidden char, not nan(n-char-seq-opt) - } - } + answer.ptr = (first += 3); + value = minusSign ? -std::numeric_limits<T>::quiet_NaN() : std::numeric_limits<T>::quiet_NaN(); + // Check for possible nan(n-char-seq-opt), C++17 20.19.3.7, C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan). + if(first != last && *first == '(') { + for(const char* ptr = first + 1; ptr != last; ++ptr) { + if (*ptr == ')') { + answer.ptr = ptr + 1; // valid nan(n-char-seq-opt) + break; + } + else if(!(('a' <= *ptr && *ptr <= 'z') || ('A' <= *ptr && *ptr <= 'Z') || ('0' <= *ptr && *ptr <= '9') || *ptr == '_')) + break; // forbidden char, not nan(n-char-seq-opt) + } + } return answer; } if (fastfloat_strncasecmp(first, "inf", 3)) { - if ((last - first >= 8) && fastfloat_strncasecmp(first + 3, "inity", 5)) { + if ((last - first >= 8) && fastfloat_strncasecmp(first + 3, "inity", 5)) { answer.ptr = first + 8; } else { answer.ptr = first + 3; } - value = minusSign ? -std::numeric_limits<T>::infinity() : std::numeric_limits<T>::infinity(); + value = minusSign ? -std::numeric_limits<T>::infinity() : std::numeric_limits<T>::infinity(); return answer; } } @@ -60,18 +60,18 @@ from_chars_result parse_infnan(const char *first, const char *last, T &value) n return answer; } -} // namespace detail +} // namespace detail template<typename T> from_chars_result from_chars(const char *first, const char *last, T &value, chars_format fmt /*= chars_format::general*/) noexcept { - return from_chars_advanced(first, last, value, parse_options{fmt}); -} - -template<typename T> -from_chars_result from_chars_advanced(const char *first, const char *last, - T &value, parse_options options) noexcept { - + return from_chars_advanced(first, last, value, parse_options{fmt}); +} + +template<typename T> +from_chars_result from_chars_advanced(const char *first, const char *last, + T &value, parse_options options) noexcept { + static_assert (std::is_same<T, double>::value || std::is_same<T, float>::value, "only float and double are supported"); @@ -81,26 +81,26 @@ from_chars_result from_chars_advanced(const char *first, const char *last, answer.ptr = first; return answer; } - parsed_number_string pns = parse_number_string(first, last, options); + parsed_number_string pns = parse_number_string(first, last, options); if (!pns.valid) { - return detail::parse_infnan(first, last, value); + return detail::parse_infnan(first, last, value); } answer.ec = std::errc(); // be optimistic answer.ptr = pns.lastmatch; // Next is Clinger's fast path. - if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format<T>::max_exponent_fast_path() && pns.mantissa <=binary_format<T>::max_mantissa_fast_path() && !pns.too_many_digits) { + if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format<T>::max_exponent_fast_path() && pns.mantissa <=binary_format<T>::max_mantissa_fast_path() && !pns.too_many_digits) { value = T(pns.mantissa); if (pns.exponent < 0) { value = value / binary_format<T>::exact_power_of_ten(-pns.exponent); } else { value = value * binary_format<T>::exact_power_of_ten(pns.exponent); } if (pns.negative) { value = -value; } return answer; } - adjusted_mantissa am = compute_float<binary_format<T>>(pns.exponent, pns.mantissa); + adjusted_mantissa am = compute_float<binary_format<T>>(pns.exponent, pns.mantissa); if(pns.too_many_digits && am.power2 >= 0) { - if(am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) { + if(am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) { am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa); - } - } + } + } // If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa) and we have an invalid power (am.power2 < 0), // then we need to go the long way around again. This is very uncommon. if(am.power2 < 0) { am = digit_comp<T>(pns, am); } diff --git a/contrib/restricted/fast_float/include/fast_float/simple_decimal_conversion.h b/contrib/restricted/fast_float/include/fast_float/simple_decimal_conversion.h index e87801480b..f3b66b0b10 100644 --- a/contrib/restricted/fast_float/include/fast_float/simple_decimal_conversion.h +++ b/contrib/restricted/fast_float/include/fast_float/simple_decimal_conversion.h @@ -19,7 +19,7 @@ namespace fast_float { -namespace detail { +namespace detail { // remove all final zeroes inline void trim(decimal &h) { @@ -30,7 +30,7 @@ inline void trim(decimal &h) { -inline uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t shift) { +inline uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t shift) { shift &= 63; constexpr uint16_t number_of_digits_decimal_left_shift_table[65] = { 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, @@ -123,7 +123,7 @@ inline uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t s return num_new_digits; } -inline uint64_t round(decimal &h) { +inline uint64_t round(decimal &h) { if ((h.num_digits == 0) || (h.decimal_point < 0)) { return 0; } else if (h.decimal_point > 18) { @@ -150,7 +150,7 @@ inline uint64_t round(decimal &h) { } // computes h * 2^-shift -inline void decimal_left_shift(decimal &h, uint32_t shift) { +inline void decimal_left_shift(decimal &h, uint32_t shift) { if (h.num_digits == 0) { return; } @@ -192,7 +192,7 @@ inline void decimal_left_shift(decimal &h, uint32_t shift) { } // computes h * 2^shift -inline void decimal_right_shift(decimal &h, uint32_t shift) { +inline void decimal_right_shift(decimal &h, uint32_t shift) { uint32_t read_index = 0; uint32_t write_index = 0; @@ -238,7 +238,7 @@ inline void decimal_right_shift(decimal &h, uint32_t shift) { trim(h); } -} // namespace detail +} // namespace detail template <typename binary> adjusted_mantissa compute_float(decimal &d) { @@ -280,8 +280,8 @@ adjusted_mantissa compute_float(decimal &d) { int32_t exp2 = 0; while (d.decimal_point > 0) { uint32_t n = uint32_t(d.decimal_point); - uint32_t shift = (n < num_powers) ? decimal_powers[n] : max_shift; - detail::decimal_right_shift(d, shift); + uint32_t shift = (n < num_powers) ? decimal_powers[n] : max_shift; + detail::decimal_right_shift(d, shift); if (d.decimal_point < -decimal_point_range) { // should be zero answer.power2 = 0; @@ -300,12 +300,12 @@ adjusted_mantissa compute_float(decimal &d) { shift = (d.digits[0] < 2) ? 2 : 1; } else { uint32_t n = uint32_t(-d.decimal_point); - shift = (n < num_powers) ? decimal_powers[n] : max_shift; + shift = (n < num_powers) ? decimal_powers[n] : max_shift; } - detail::decimal_left_shift(d, shift); + detail::decimal_left_shift(d, shift); if (d.decimal_point > decimal_point_range) { // we want to get infinity: - answer.power2 = binary::infinite_power(); + answer.power2 = binary::infinite_power(); answer.mantissa = 0; return answer; } @@ -319,7 +319,7 @@ adjusted_mantissa compute_float(decimal &d) { if (n > max_shift) { n = max_shift; } - detail::decimal_right_shift(d, n); + detail::decimal_right_shift(d, n); exp2 += int32_t(n); } if ((exp2 - minimum_exponent) >= binary::infinite_power()) { @@ -329,15 +329,15 @@ adjusted_mantissa compute_float(decimal &d) { } const int mantissa_size_in_bits = binary::mantissa_explicit_bits() + 1; - detail::decimal_left_shift(d, mantissa_size_in_bits); + detail::decimal_left_shift(d, mantissa_size_in_bits); - uint64_t mantissa = detail::round(d); + uint64_t mantissa = detail::round(d); // It is possible that we have an overflow, in which case we need // to shift back. if(mantissa >= (uint64_t(1) << mantissa_size_in_bits)) { - detail::decimal_right_shift(d, 1); + detail::decimal_right_shift(d, 1); exp2 += 1; - mantissa = detail::round(d); + mantissa = detail::round(d); if ((exp2 - minimum_exponent) >= binary::infinite_power()) { answer.power2 = binary::infinite_power(); answer.mantissa = 0; @@ -351,8 +351,8 @@ adjusted_mantissa compute_float(decimal &d) { } template <typename binary> -adjusted_mantissa parse_long_mantissa(const char *first, const char* last, parse_options options) { - decimal d = parse_decimal(first, last, options); +adjusted_mantissa parse_long_mantissa(const char *first, const char* last, parse_options options) { + decimal d = parse_decimal(first, last, options); return compute_float<binary>(d); } diff --git a/contrib/restricted/fast_float/ya.make b/contrib/restricted/fast_float/ya.make index dd331096b3..b3e87bb472 100644 --- a/contrib/restricted/fast_float/ya.make +++ b/contrib/restricted/fast_float/ya.make @@ -1,6 +1,6 @@ # Generated by devtools/yamaker from nixpkgs 21.11. -LIBRARY() +LIBRARY() LICENSE( Apache-2.0 AND @@ -21,8 +21,8 @@ ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v3.4.0.tar.gz) NO_COMPILER_WARNINGS() -NO_RUNTIME() +NO_RUNTIME() -NO_UTIL() +NO_UTIL() END() |