mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Merge branch 'main' into main
This commit is contained in:
commit
593709f056
@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
## fast_float number parsing library: 4x faster than strtod
|
## fast_float number parsing library: 4x faster than strtod
|
||||||
|
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:fast_float)
|
||||||
|
[](https://github.com/fastfloat/fast_float/actions/workflows/vs17-ci.yml)
|
||||||
|
[](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml)
|
||||||
|
|
||||||
The fast_float library provides fast header-only implementations for the C++ from_chars
|
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
|
functions for `float` and `double` types. These functions convert ASCII strings representing
|
||||||
|
|||||||
@ -119,7 +119,7 @@ parsed_number_string_t<TCH> parse_number_string(TCH const *p, TCH const * pend,
|
|||||||
answer.valid = false;
|
answer.valid = false;
|
||||||
answer.too_many_digits = false;
|
answer.too_many_digits = false;
|
||||||
answer.negative = (*p == TCH('-'));
|
answer.negative = (*p == TCH('-'));
|
||||||
#if FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
||||||
if ((*p == TCH('-')) || (*p == TCH('+'))) {
|
if ((*p == TCH('-')) || (*p == TCH('+'))) {
|
||||||
#else
|
#else
|
||||||
if (*p == TCH('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
if (*p == TCH('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
||||||
|
|||||||
@ -14,13 +14,13 @@
|
|||||||
#define FASTFLOAT_CONSTEXPR14
|
#define FASTFLOAT_CONSTEXPR14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cpp_lib_bit_cast >= 201806L
|
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
|
||||||
#define FASTFLOAT_HAS_BIT_CAST 1
|
#define FASTFLOAT_HAS_BIT_CAST 1
|
||||||
#else
|
#else
|
||||||
#define FASTFLOAT_HAS_BIT_CAST 0
|
#define FASTFLOAT_HAS_BIT_CAST 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cpp_lib_is_constant_evaluated >= 201811L
|
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
||||||
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1
|
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1
|
||||||
#else
|
#else
|
||||||
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0
|
#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0
|
||||||
|
|||||||
@ -482,7 +482,7 @@ void to_float(bool negative, adjusted_mantissa am, T &value) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
|
#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
|
||||||
template <typename = void>
|
template <typename = void>
|
||||||
struct space_lut {
|
struct space_lut {
|
||||||
static constexpr bool value[] = {
|
static constexpr bool value[] = {
|
||||||
|
|||||||
@ -30,7 +30,7 @@ parse_infnan(TCH const * first, TCH const * last, T &value) noexcept {
|
|||||||
minusSign = true;
|
minusSign = true;
|
||||||
++first;
|
++first;
|
||||||
}
|
}
|
||||||
#if FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
||||||
if (*first == TCH('+')) {
|
if (*first == TCH('+')) {
|
||||||
++first;
|
++first;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
|
|||||||
//
|
//
|
||||||
// Note: This may fail to be accurate if fast-math has been
|
// Note: This may fail to be accurate if fast-math has been
|
||||||
// enabled, as rounding conventions may not apply.
|
// enabled, as rounding conventions may not apply.
|
||||||
#if FASTFLOAT_VISUAL_STUDIO
|
#ifdef FASTFLOAT_VISUAL_STUDIO
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
// todo: is there a VS warning?
|
// todo: is there a VS warning?
|
||||||
// see https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
|
// see https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
|
||||||
@ -121,7 +121,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
|
|||||||
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||||
#endif
|
#endif
|
||||||
return (fmini + 1.0f == 1.0f - fmini);
|
return (fmini + 1.0f == 1.0f - fmini);
|
||||||
#if FASTFLOAT_VISUAL_STUDIO
|
#ifdef FASTFLOAT_VISUAL_STUDIO
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
# pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
@ -151,7 +151,7 @@ from_chars_result_t<TCH> from_chars_advanced(TCH const * first, TCH const * last
|
|||||||
std::is_same<TCH, char32_t>::value , "only char, wchar_t, char16_t and char32_t are supported");
|
std::is_same<TCH, char32_t>::value , "only char, wchar_t, char16_t and char32_t are supported");
|
||||||
|
|
||||||
from_chars_result_t<TCH> answer;
|
from_chars_result_t<TCH> answer;
|
||||||
#if FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
|
#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
|
||||||
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
|
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
|
||||||
first++;
|
first++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user