From fcdb5869d4b5106d5e2e8efd32ec0fb3f8f1ae02 Mon Sep 17 00:00:00 2001 From: IRainman Date: Tue, 30 Dec 2025 00:39:02 +0300 Subject: [PATCH] cleanup in the API. --- include/fast_float/fast_float.h | 10 ++++----- include/fast_float/parse_number.h | 35 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/include/fast_float/fast_float.h b/include/fast_float/fast_float.h index b478e65..4bb8544 100644 --- a/include/fast_float/fast_float.h +++ b/include/fast_float/fast_float.h @@ -60,10 +60,10 @@ from_chars_advanced(UC const *first, UC const *last, T &value, */ FASTFLOAT_CONSTEXPR20 inline double integer_times_pow10(uint64_t const mantissa, - am_pow_t const decimal_exponent) noexcept; + int const decimal_exponent) noexcept; FASTFLOAT_CONSTEXPR20 inline double integer_times_pow10(int64_t const mantissa, - am_pow_t const decimal_exponent) noexcept; + int const decimal_exponent) noexcept; /** * This function is a template overload of `integer_times_pow10()` @@ -74,12 +74,12 @@ template FASTFLOAT_CONSTEXPR20 typename std::enable_if::value, T>::type integer_times_pow10(uint64_t const mantissa, - am_pow_t const decimal_exponent) noexcept; + int const decimal_exponent) noexcept; template FASTFLOAT_CONSTEXPR20 typename std::enable_if::value, T>::type integer_times_pow10(int64_t const mantissa, - am_pow_t const decimal_exponent) noexcept; + int const decimal_exponent) noexcept; /** * from_chars for integer types. @@ -88,7 +88,7 @@ template ::value)> FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars(UC const *first, UC const *last, T &value, - base_t const base = 10) noexcept; + int const base = 10) noexcept; } // namespace fast_float diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 4a04ff1..b3b8335 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -376,15 +376,15 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value, template FASTFLOAT_CONSTEXPR20 from_chars_result_t -from_chars(UC const *first, UC const *last, T &value, - base_t const base) noexcept { +from_chars(UC const *first, UC const *last, T &value, int const base) noexcept { static_assert(is_supported_integer_type::value, "only integer types are supported"); static_assert(is_supported_char_type::value, "only char, wchar_t, char16_t and char32_t are supported"); - parse_options_t const options(chars_format::general, UC('.'), base); + parse_options_t const options(chars_format::general, UC('.'), + static_cast(base)); return from_chars_advanced(first, last, value, options); } @@ -392,17 +392,17 @@ template FASTFLOAT_CONSTEXPR20 typename std::enable_if::value, T>::type integer_times_pow10(uint64_t const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { T value; - if (clinger_fast_path_impl(mantissa, decimal_exponent, + const auto exponent = static_cast(decimal_exponent); + if (clinger_fast_path_impl(mantissa, exponent, #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN false, #endif value)) return value; - adjusted_mantissa am = - compute_float>(decimal_exponent, mantissa); + adjusted_mantissa am = compute_float>(exponent, mantissa); to_float( #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN false, @@ -415,7 +415,7 @@ template FASTFLOAT_CONSTEXPR20 typename std::enable_if::value, T>::type integer_times_pow10(int64_t const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN const auto is_negative = mantissa < 0; const auto m = static_cast(is_negative ? -mantissa : mantissa); @@ -423,8 +423,9 @@ FASTFLOAT_CONSTEXPR20 FASTFLOAT_ASSUME(mantissa >= 0); const auto m = static_cast(mantissa); #endif + const auto exponent = static_cast(decimal_exponent); T value; - if (clinger_fast_path_impl(m, decimal_exponent, + if (clinger_fast_path_impl(m, exponent, #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN is_negative, #endif @@ -432,7 +433,7 @@ FASTFLOAT_CONSTEXPR20 return value; adjusted_mantissa const am = - compute_float>(decimal_exponent, m); + compute_float>(exponent, m); to_float( #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN @@ -444,13 +445,13 @@ FASTFLOAT_CONSTEXPR20 FASTFLOAT_CONSTEXPR20 inline double integer_times_pow10(uint64_t const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { return integer_times_pow10(mantissa, decimal_exponent); } FASTFLOAT_CONSTEXPR20 inline double integer_times_pow10(int64_t const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { return integer_times_pow10(mantissa, decimal_exponent); } @@ -463,7 +464,7 @@ FASTFLOAT_CONSTEXPR20 !std::is_signed::value, T>::type integer_times_pow10(Int const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { return integer_times_pow10(static_cast(mantissa), decimal_exponent); } @@ -475,7 +476,7 @@ FASTFLOAT_CONSTEXPR20 std::is_signed::value, T>::type integer_times_pow10(Int const mantissa, - am_pow_t const decimal_exponent) noexcept { + int const decimal_exponent) noexcept { return integer_times_pow10(static_cast(mantissa), decimal_exponent); } @@ -483,16 +484,14 @@ FASTFLOAT_CONSTEXPR20 template FASTFLOAT_CONSTEXPR20 typename std::enable_if< std::is_integral::value && !std::is_signed::value, double>::type -integer_times_pow10(Int const mantissa, - am_pow_t const decimal_exponent) noexcept { +integer_times_pow10(Int const mantissa, int const decimal_exponent) noexcept { return integer_times_pow10(static_cast(mantissa), decimal_exponent); } template FASTFLOAT_CONSTEXPR20 typename std::enable_if< std::is_integral::value && std::is_signed::value, double>::type -integer_times_pow10(Int const mantissa, - am_pow_t const decimal_exponent) noexcept { +integer_times_pow10(Int const mantissa, int const decimal_exponent) noexcept { return integer_times_pow10(static_cast(mantissa), decimal_exponent); }