mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
# format.
This commit is contained in:
parent
ba1344c030
commit
0a18d6b329
@ -334,8 +334,7 @@ parse_number_string(UC const *p, UC const *pend,
|
||||
// multiplication
|
||||
answer.mantissa =
|
||||
10 * answer.mantissa +
|
||||
UC(*p -
|
||||
UC('0')); // might overflow, we will handle the overflow later
|
||||
UC(*p - UC('0')); // might overflow, we will handle the overflow later
|
||||
++p;
|
||||
}
|
||||
UC const *const end_of_integer_part = p;
|
||||
@ -371,7 +370,8 @@ parse_number_string(UC const *p, UC const *pend,
|
||||
++p;
|
||||
}
|
||||
answer.exponent = static_cast<am_pow_t>(before - p);
|
||||
answer.fraction = span<UC const>(before, static_cast<am_digits>(p - before));
|
||||
answer.fraction =
|
||||
span<UC const>(before, static_cast<am_digits>(p - before));
|
||||
digit_count -= answer.exponent;
|
||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
FASTFLOAT_IF_CONSTEXPR17(basic_json_fmt) {
|
||||
@ -390,7 +390,8 @@ parse_number_string(UC const *p, UC const *pend,
|
||||
|
||||
// Now we can parse the explicit exponential part.
|
||||
am_pow_t exp_number = 0; // explicit exponential part
|
||||
if ((p != pend) && (chars_format_t(options.format & chars_format::scientific) &&
|
||||
if ((p != pend) &&
|
||||
(chars_format_t(options.format & chars_format::scientific) &&
|
||||
(UC('e') == *p) ||
|
||||
(UC('E') == *p))
|
||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
|
||||
@ -147,7 +147,8 @@ template <typename callback>
|
||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void
|
||||
round_nearest_tie_even(adjusted_mantissa &am, am_pow_t shift,
|
||||
callback cb) noexcept {
|
||||
am_mant_t const mask = (shift == 64) ? UINT64_MAX : (am_mant_t(1) << shift) - 1;
|
||||
am_mant_t const mask =
|
||||
(shift == 64) ? UINT64_MAX : (am_mant_t(1) << shift) - 1;
|
||||
am_mant_t const halfway = (shift == 0) ? 0 : am_mant_t(1) << (shift - 1);
|
||||
am_mant_t truncated_bits = am.mantissa & mask;
|
||||
bool is_above = truncated_bits > halfway;
|
||||
@ -385,8 +386,9 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp(
|
||||
adjusted_mantissa am_b = am;
|
||||
// gcc7 bug: use a lambda to remove the noexcept qualifier bug with
|
||||
// -Wnoexcept-type.
|
||||
round<T>(am_b,
|
||||
[](adjusted_mantissa &a, am_pow_t shift) { round_down(a, shift); });
|
||||
round<T>(am_b, [](adjusted_mantissa &a, am_pow_t shift) {
|
||||
round_down(a, shift);
|
||||
});
|
||||
to_float(
|
||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
false,
|
||||
|
||||
@ -408,9 +408,8 @@ umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) noexcept {
|
||||
|
||||
// slow emulation routine for 32-bit
|
||||
#if !defined(__MINGW64__)
|
||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t _umul128(uint64_t ab,
|
||||
uint64_t cd,
|
||||
uint64_t *hi) noexcept {
|
||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t
|
||||
_umul128(uint64_t ab, uint64_t cd, uint64_t *hi) noexcept {
|
||||
return umul128_generic(ab, cd, hi);
|
||||
}
|
||||
#endif // !__MINGW64__
|
||||
@ -630,7 +629,8 @@ inline constexpr am_pow_t binary_format<float>::min_exponent_round_to_even() {
|
||||
return -17;
|
||||
}
|
||||
|
||||
template <> inline constexpr am_pow_t binary_format<double>::minimum_exponent() {
|
||||
template <>
|
||||
inline constexpr am_pow_t binary_format<double>::minimum_exponent() {
|
||||
return -1023;
|
||||
}
|
||||
|
||||
@ -669,7 +669,8 @@ inline constexpr am_pow_t binary_format<float>::max_exponent_fast_path() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline constexpr binary_format<T>::equiv_uint binary_format<T>::max_mantissa_fast_path() {
|
||||
inline constexpr binary_format<T>::equiv_uint
|
||||
binary_format<T>::max_mantissa_fast_path() {
|
||||
return binary_format<T>::equiv_uint(2) << mantissa_explicit_bits();
|
||||
}
|
||||
|
||||
@ -786,7 +787,8 @@ inline constexpr am_bits_t binary_format<std::float16_t>::sign_index() {
|
||||
#endif
|
||||
|
||||
template <>
|
||||
inline constexpr am_exp_t binary_format<std::float16_t>::largest_power_of_ten() {
|
||||
inline constexpr am_exp_t
|
||||
binary_format<std::float16_t>::largest_power_of_ten() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -1197,7 +1199,8 @@ fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) noexcept {
|
||||
return int_luts<>::chdigit[static_cast<unsigned char>(c)];
|
||||
}
|
||||
|
||||
fastfloat_really_inline constexpr uint8_t max_digits_u64(uint8_t base) noexcept {
|
||||
fastfloat_really_inline constexpr uint8_t
|
||||
max_digits_u64(uint8_t base) noexcept {
|
||||
return int_luts<>::maxdigits_u64[base - 2];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user