mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Compare commits
3 Commits
497e65b03f
...
c9d0ac0084
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9d0ac0084 | ||
|
|
597c239218 | ||
|
|
b8163709f5 |
@ -369,7 +369,7 @@ FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename = void> struct pow5_tables {
|
template <typename = void> struct pow5_tables {
|
||||||
static constexpr uint8_t large_step = 135;
|
static constexpr uint_fast8_t large_step = 135;
|
||||||
static constexpr uint64_t small_power_of_5[] = {
|
static constexpr uint64_t small_power_of_5[] = {
|
||||||
1UL,
|
1UL,
|
||||||
5UL,
|
5UL,
|
||||||
@ -413,7 +413,7 @@ template <typename = void> struct pow5_tables {
|
|||||||
|
|
||||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||||
|
|
||||||
template <typename T> constexpr uint8_t pow5_tables<T>::large_step;
|
template <typename T> constexpr uint_fast8_t pow5_tables<T>::large_step;
|
||||||
|
|
||||||
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
|
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
|
||||||
|
|
||||||
|
|||||||
@ -60,10 +60,10 @@ from_chars_advanced(UC const *first, UC const *last, T &value,
|
|||||||
*/
|
*/
|
||||||
FASTFLOAT_CONSTEXPR20 inline double
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
integer_times_pow10(uint64_t const mantissa,
|
integer_times_pow10(uint64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept;
|
int_fast16_t const decimal_exponent) noexcept;
|
||||||
FASTFLOAT_CONSTEXPR20 inline double
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
integer_times_pow10(int64_t const mantissa,
|
integer_times_pow10(int64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept;
|
int_fast16_t const decimal_exponent) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is a template overload of `integer_times_pow10()`
|
* This function is a template overload of `integer_times_pow10()`
|
||||||
@ -74,12 +74,12 @@ template <typename T>
|
|||||||
FASTFLOAT_CONSTEXPR20
|
FASTFLOAT_CONSTEXPR20
|
||||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||||
integer_times_pow10(uint64_t const mantissa,
|
integer_times_pow10(uint64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept;
|
int_fast16_t const decimal_exponent) noexcept;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FASTFLOAT_CONSTEXPR20
|
FASTFLOAT_CONSTEXPR20
|
||||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||||
integer_times_pow10(int64_t const mantissa,
|
integer_times_pow10(int64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept;
|
int_fast16_t const decimal_exponent) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* from_chars for integer types.
|
* from_chars for integer types.
|
||||||
@ -88,7 +88,7 @@ template <typename T, typename UC = char,
|
|||||||
typename = FASTFLOAT_ENABLE_IF(is_supported_integer_type<T>::value)>
|
typename = FASTFLOAT_ENABLE_IF(is_supported_integer_type<T>::value)>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars(UC const *first, UC const *last, T &value,
|
from_chars(UC const *first, UC const *last, T &value,
|
||||||
int const base = 10) noexcept;
|
uint_fast8_t const base = 10) noexcept;
|
||||||
|
|
||||||
} // namespace fast_float
|
} // namespace fast_float
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,8 @@ enum class chars_format : chars_format_t;
|
|||||||
|
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
namespace detail {
|
namespace detail {
|
||||||
constexpr chars_format basic_json_fmt = chars_format(1 << 4);
|
constexpr chars_format basic_json_fmt = chars_format(1 << 6);
|
||||||
constexpr chars_format basic_fortran_fmt = chars_format(1 << 5);
|
constexpr chars_format basic_fortran_fmt = chars_format(1 << 7);
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -57,13 +57,13 @@ enum class chars_format : chars_format_t {
|
|||||||
hex = 1 << 2,
|
hex = 1 << 2,
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
no_infnan = 1 << 3,
|
no_infnan = 1 << 3,
|
||||||
|
allow_leading_plus = 1 << 4,
|
||||||
|
skip_white_space = 1 << 5,
|
||||||
// RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6
|
// RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6
|
||||||
json = chars_format_t(detail::basic_json_fmt) | general | no_infnan,
|
json = chars_format_t(detail::basic_json_fmt) | general | no_infnan,
|
||||||
// Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed.
|
// Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed.
|
||||||
json_or_infnan = chars_format_t(detail::basic_json_fmt) | general,
|
json_or_infnan = chars_format_t(detail::basic_json_fmt) | general,
|
||||||
fortran = chars_format_t(detail::basic_fortran_fmt) | general,
|
fortran = chars_format_t(detail::basic_fortran_fmt) | general,
|
||||||
allow_leading_plus = 1 << 6,
|
|
||||||
skip_white_space = 1 << 7,
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,9 +83,7 @@ template <typename UC> struct parse_options_t {
|
|||||||
constexpr explicit parse_options_t(
|
constexpr explicit parse_options_t(
|
||||||
chars_format const fmt = chars_format::general, UC const dot = UC('.'),
|
chars_format const fmt = chars_format::general, UC const dot = UC('.'),
|
||||||
uint_fast8_t const b = 10) noexcept
|
uint_fast8_t const b = 10) noexcept
|
||||||
: format(fmt), decimal_point(dot), base(b) {
|
: format(fmt), decimal_point(dot), base(b) {}
|
||||||
FASTFLOAT_ASSUME(base >= 2 && base <= 36);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Which number formats are accepted */
|
/** Which number formats are accepted */
|
||||||
chars_format format;
|
chars_format format;
|
||||||
@ -287,8 +285,8 @@ struct is_supported_char_type
|
|||||||
template <typename UC>
|
template <typename UC>
|
||||||
inline FASTFLOAT_CONSTEXPR14 bool
|
inline FASTFLOAT_CONSTEXPR14 bool
|
||||||
fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
|
fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
|
||||||
uint8_t const length) noexcept {
|
uint_fast8_t const length) noexcept {
|
||||||
for (uint8_t i = 0; i++ != length;) {
|
for (uint_fast8_t i = 0; i++ != length;) {
|
||||||
UC const actual = actual_mixedcase[i];
|
UC const actual = actual_mixedcase[i];
|
||||||
if ((actual < 256 ? actual | 32 : actual) != expected_lowercase[i]) {
|
if ((actual < 256 ? actual | 32 : actual) != expected_lowercase[i]) {
|
||||||
return false;
|
return false;
|
||||||
@ -1059,7 +1057,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void to_float(
|
|||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
|
|
||||||
template <typename = void> struct space_lut {
|
template <typename = void> struct space_lut {
|
||||||
static constexpr uint8_t value[] = {
|
static constexpr uint_fast8_t value[] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@ -1075,12 +1073,12 @@ template <typename = void> struct space_lut {
|
|||||||
|
|
||||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||||
|
|
||||||
template <typename T> constexpr uint8_t space_lut<T>::value[];
|
template <typename T> constexpr uint_fast8_t space_lut<T>::value[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename UC> constexpr bool is_space(UC c) {
|
template <typename UC> constexpr bool is_space(UC c) {
|
||||||
return c < 256 && space_lut<>::value[uint8_t(c)];
|
return c < 256 && space_lut<>::value[uint_fast8_t(c)];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1166,7 +1164,7 @@ template <typename = void> struct int_luts {
|
|||||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
255};
|
255};
|
||||||
|
|
||||||
static constexpr uint8_t maxdigits_u64[] = {
|
static constexpr uint_fast8_t maxdigits_u64[] = {
|
||||||
64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16,
|
64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16,
|
||||||
15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13};
|
15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13};
|
||||||
|
|
||||||
@ -1187,9 +1185,9 @@ template <typename = void> struct int_luts {
|
|||||||
|
|
||||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||||
|
|
||||||
template <typename T> constexpr uint8_t int_luts<T>::chdigit[];
|
template <typename T> constexpr uint_fast8_t int_luts<T>::chdigit[];
|
||||||
|
|
||||||
template <typename T> constexpr uint8_t int_luts<T>::maxdigits_u64[];
|
template <typename T> constexpr uint_fast8_t int_luts<T>::maxdigits_u64[];
|
||||||
|
|
||||||
template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
|
template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
|
||||||
|
|
||||||
|
|||||||
@ -374,15 +374,15 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
|||||||
|
|
||||||
template <typename T, typename UC, typename>
|
template <typename T, typename UC, typename>
|
||||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||||
from_chars(UC const *first, UC const *last, T &value, int const base) noexcept {
|
from_chars(UC const *first, UC const *last, T &value,
|
||||||
|
uint_fast8_t const base) noexcept {
|
||||||
|
|
||||||
static_assert(is_supported_integer_type<T>::value,
|
static_assert(is_supported_integer_type<T>::value,
|
||||||
"only integer types are supported");
|
"only integer types are supported");
|
||||||
static_assert(is_supported_char_type<UC>::value,
|
static_assert(is_supported_char_type<UC>::value,
|
||||||
"only char, wchar_t, char16_t and char32_t are supported");
|
"only char, wchar_t, char16_t and char32_t are supported");
|
||||||
|
|
||||||
parse_options_t<UC> const options(chars_format::general, UC('.'),
|
parse_options_t<UC> const options(chars_format::general, UC('.'), base);
|
||||||
static_cast<uint_fast8_t>(base));
|
|
||||||
return from_chars_advanced(first, last, value, options);
|
return from_chars_advanced(first, last, value, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ template <typename T>
|
|||||||
FASTFLOAT_CONSTEXPR20
|
FASTFLOAT_CONSTEXPR20
|
||||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||||
integer_times_pow10(uint64_t const mantissa,
|
integer_times_pow10(uint64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept {
|
int_fast16_t const decimal_exponent) noexcept {
|
||||||
T value;
|
T value;
|
||||||
if (clinger_fast_path_impl(mantissa, decimal_exponent,
|
if (clinger_fast_path_impl(mantissa, decimal_exponent,
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
@ -413,7 +413,7 @@ template <typename T>
|
|||||||
FASTFLOAT_CONSTEXPR20
|
FASTFLOAT_CONSTEXPR20
|
||||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||||
integer_times_pow10(int64_t const mantissa,
|
integer_times_pow10(int64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept {
|
int_fast16_t const decimal_exponent) noexcept {
|
||||||
#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
FASTFLOAT_ASSUME(mantissa > 0);
|
FASTFLOAT_ASSUME(mantissa > 0);
|
||||||
const am_mant_t m = static_cast<am_mant_t>(mantissa);
|
const am_mant_t m = static_cast<am_mant_t>(mantissa);
|
||||||
@ -442,13 +442,13 @@ FASTFLOAT_CONSTEXPR20
|
|||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline double
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
integer_times_pow10(uint64_t const mantissa,
|
integer_times_pow10(uint64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept {
|
int_fast16_t const decimal_exponent) noexcept {
|
||||||
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline double
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
integer_times_pow10(int64_t const mantissa,
|
integer_times_pow10(int64_t const mantissa,
|
||||||
int16_t const decimal_exponent) noexcept {
|
int_fast16_t const decimal_exponent) noexcept {
|
||||||
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ FASTFLOAT_CONSTEXPR20
|
|||||||
std::is_integral<Int>::value &&
|
std::is_integral<Int>::value &&
|
||||||
!std::is_signed<Int>::value,
|
!std::is_signed<Int>::value,
|
||||||
T>::type
|
T>::type
|
||||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||||
return integer_times_pow10<T>(static_cast<uint64_t>(mantissa),
|
return integer_times_pow10<T>(static_cast<uint64_t>(mantissa),
|
||||||
decimal_exponent);
|
decimal_exponent);
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ FASTFLOAT_CONSTEXPR20
|
|||||||
std::is_integral<Int>::value &&
|
std::is_integral<Int>::value &&
|
||||||
std::is_signed<Int>::value,
|
std::is_signed<Int>::value,
|
||||||
T>::type
|
T>::type
|
||||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||||
return integer_times_pow10<T>(static_cast<int64_t>(mantissa),
|
return integer_times_pow10<T>(static_cast<int64_t>(mantissa),
|
||||||
decimal_exponent);
|
decimal_exponent);
|
||||||
}
|
}
|
||||||
@ -479,14 +479,14 @@ FASTFLOAT_CONSTEXPR20
|
|||||||
template <typename Int>
|
template <typename Int>
|
||||||
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
||||||
std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
|
std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
|
||||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||||
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
|
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Int>
|
template <typename Int>
|
||||||
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
||||||
std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
|
std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
|
||||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||||
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
|
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2127,7 +2127,7 @@ TEST_CASE("bfloat16.general") {
|
|||||||
|
|
||||||
template <typename Int, typename T, typename U>
|
template <typename Int, typename T, typename U>
|
||||||
void verify_integer_times_pow10_result(Int const mantissa,
|
void verify_integer_times_pow10_result(Int const mantissa,
|
||||||
int16_t const decimal_exponent,
|
int_fast16_t const decimal_exponent,
|
||||||
T const actual, U const expected) {
|
T const actual, U const expected) {
|
||||||
static_assert(std::is_same<T, U>::value,
|
static_assert(std::is_same<T, U>::value,
|
||||||
"expected and actual types must match");
|
"expected and actual types must match");
|
||||||
@ -2146,7 +2146,7 @@ void verify_integer_times_pow10_result(Int const mantissa,
|
|||||||
|
|
||||||
template <typename T, typename Int>
|
template <typename T, typename Int>
|
||||||
T calculate_integer_times_pow10_expected_result(
|
T calculate_integer_times_pow10_expected_result(
|
||||||
Int const mantissa, int16_t const decimal_exponent) {
|
Int const mantissa, int_fast16_t const decimal_exponent) {
|
||||||
std::string constructed_string =
|
std::string constructed_string =
|
||||||
std::to_string(mantissa) + "e" + std::to_string(decimal_exponent);
|
std::to_string(mantissa) + "e" + std::to_string(decimal_exponent);
|
||||||
T expected_result;
|
T expected_result;
|
||||||
@ -2160,7 +2160,7 @@ T calculate_integer_times_pow10_expected_result(
|
|||||||
|
|
||||||
template <typename Int>
|
template <typename Int>
|
||||||
void verify_integer_times_pow10_dflt(Int const mantissa,
|
void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||||
int16_t const decimal_exponent,
|
int_fast16_t const decimal_exponent,
|
||||||
double const expected) {
|
double const expected) {
|
||||||
static_assert(std::is_integral<Int>::value);
|
static_assert(std::is_integral<Int>::value);
|
||||||
|
|
||||||
@ -2174,7 +2174,7 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
|
|||||||
|
|
||||||
template <typename Int>
|
template <typename Int>
|
||||||
void verify_integer_times_pow10_dflt(Int const mantissa,
|
void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||||
int16_t const decimal_exponent) {
|
int_fast16_t const decimal_exponent) {
|
||||||
static_assert(std::is_integral<Int>::value);
|
static_assert(std::is_integral<Int>::value);
|
||||||
|
|
||||||
const auto expected_result =
|
const auto expected_result =
|
||||||
@ -2186,7 +2186,7 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
|
|||||||
|
|
||||||
template <typename T, typename Int>
|
template <typename T, typename Int>
|
||||||
void verify_integer_times_pow10(Int const mantissa,
|
void verify_integer_times_pow10(Int const mantissa,
|
||||||
int16_t const decimal_exponent,
|
int_fast16_t const decimal_exponent,
|
||||||
T const expected) {
|
T const expected) {
|
||||||
static_assert(std::is_floating_point<T>::value);
|
static_assert(std::is_floating_point<T>::value);
|
||||||
static_assert(std::is_integral<Int>::value);
|
static_assert(std::is_integral<Int>::value);
|
||||||
@ -2201,7 +2201,7 @@ void verify_integer_times_pow10(Int const mantissa,
|
|||||||
|
|
||||||
template <typename T, typename Int>
|
template <typename T, typename Int>
|
||||||
void verify_integer_times_pow10(Int const mantissa,
|
void verify_integer_times_pow10(Int const mantissa,
|
||||||
int16_t const decimal_exponent) {
|
int_fast16_t const decimal_exponent) {
|
||||||
static_assert(std::is_floating_point<T>::value);
|
static_assert(std::is_floating_point<T>::value);
|
||||||
static_assert(std::is_integral<Int>::value);
|
static_assert(std::is_integral<Int>::value);
|
||||||
|
|
||||||
@ -2214,7 +2214,7 @@ void verify_integer_times_pow10(Int const mantissa,
|
|||||||
namespace all_supported_types {
|
namespace all_supported_types {
|
||||||
template <typename Int>
|
template <typename Int>
|
||||||
void verify_integer_times_pow10(Int const mantissa,
|
void verify_integer_times_pow10(Int const mantissa,
|
||||||
int16_t const decimal_exponent) {
|
int_fast16_t const decimal_exponent) {
|
||||||
static_assert(std::is_integral<Int>::value);
|
static_assert(std::is_integral<Int>::value);
|
||||||
|
|
||||||
// verify the "default" overload
|
// verify the "default" overload
|
||||||
|
|||||||
@ -466,7 +466,7 @@ int main() {
|
|||||||
auto const &f = invalid_base_test_1[i];
|
auto const &f = invalid_base_test_1[i];
|
||||||
int result;
|
int result;
|
||||||
auto answer =
|
auto answer =
|
||||||
fast_float::from_chars(f.data(), f.data() + f.size(), result, -1);
|
fast_float::from_chars(f.data(), f.data() + f.size(), result, 1);
|
||||||
if (answer.ec != std::errc::invalid_argument) {
|
if (answer.ec != std::errc::invalid_argument) {
|
||||||
std::cerr << "expected error should be 'invalid_argument' for: \"" << f
|
std::cerr << "expected error should be 'invalid_argument' for: \"" << f
|
||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
@ -567,7 +567,7 @@ int main() {
|
|||||||
auto const &f = int_out_of_range_base_test[i];
|
auto const &f = int_out_of_range_base_test[i];
|
||||||
int64_t result;
|
int64_t result;
|
||||||
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
||||||
int(2 + (i / 2)));
|
uint_fast8_t(2 + (i / 2)));
|
||||||
if (answer.ec != std::errc::result_out_of_range) {
|
if (answer.ec != std::errc::result_out_of_range) {
|
||||||
std::cerr << "expected error for should be 'result_out_of_range': \"" << f
|
std::cerr << "expected error for should be 'result_out_of_range': \"" << f
|
||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
@ -612,7 +612,7 @@ int main() {
|
|||||||
"7ORP63SH4DPHI",
|
"7ORP63SH4DPHI",
|
||||||
"5G24A25TWKWFG",
|
"5G24A25TWKWFG",
|
||||||
"3W5E11264SGSG"};
|
"3W5E11264SGSG"};
|
||||||
int base_unsigned = 2;
|
uint_fast8_t base_unsigned = 2;
|
||||||
for (std::size_t i = 0; i < unsigned_out_of_range_base_test.size(); ++i) {
|
for (std::size_t i = 0; i < unsigned_out_of_range_base_test.size(); ++i) {
|
||||||
auto const &f = unsigned_out_of_range_base_test[i];
|
auto const &f = unsigned_out_of_range_base_test[i];
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
@ -703,7 +703,7 @@ int main() {
|
|||||||
auto const &f = int_within_range_base_test[i];
|
auto const &f = int_within_range_base_test[i];
|
||||||
int64_t result;
|
int64_t result;
|
||||||
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
||||||
int(2 + (i / 2)));
|
uint_fast8_t(2 + (i / 2)));
|
||||||
if (answer.ec != std::errc()) {
|
if (answer.ec != std::errc()) {
|
||||||
std::cerr << "converting " << f
|
std::cerr << "converting " << f
|
||||||
<< " to int failed (most likely out of range)" << std::endl;
|
<< " to int failed (most likely out of range)" << std::endl;
|
||||||
@ -748,7 +748,7 @@ int main() {
|
|||||||
"7ORP63SH4DPHH",
|
"7ORP63SH4DPHH",
|
||||||
"5G24A25TWKWFF",
|
"5G24A25TWKWFF",
|
||||||
"3W5E11264SGSF"};
|
"3W5E11264SGSF"};
|
||||||
int base_unsigned2 = 2;
|
uint_fast8_t base_unsigned2 = 2;
|
||||||
for (std::size_t i = 0; i < unsigned_within_range_base_test.size(); ++i) {
|
for (std::size_t i = 0; i < unsigned_within_range_base_test.size(); ++i) {
|
||||||
auto const &f = unsigned_within_range_base_test[i];
|
auto const &f = unsigned_within_range_base_test[i];
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
@ -806,7 +806,7 @@ int main() {
|
|||||||
auto const &f = int_leading_zeros_test[i];
|
auto const &f = int_leading_zeros_test[i];
|
||||||
int result;
|
int result;
|
||||||
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result,
|
||||||
int(i + 2));
|
uint_fast8_t(i + 2));
|
||||||
if (answer.ec != std::errc()) {
|
if (answer.ec != std::errc()) {
|
||||||
std::cerr << "could not convert to int for input: \"" << f << "\""
|
std::cerr << "could not convert to int for input: \"" << f << "\""
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user