mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Finally: after type refactoring is done give compiler opportunity to select best type for performance.
This commit is contained in:
parent
d67876e2f7
commit
8721491941
@ -32,7 +32,7 @@ typedef span<limb> limb_span;
|
|||||||
// of bits required to store the largest bigint, which is
|
// of bits required to store the largest bigint, which is
|
||||||
// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or
|
// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or
|
||||||
// ~3600 bits, so we round to 4000.
|
// ~3600 bits, so we round to 4000.
|
||||||
typedef uint16_t bigint_bits_t;
|
typedef uint_fast16_t bigint_bits_t;
|
||||||
constexpr bigint_bits_t bigint_bits = 4000;
|
constexpr bigint_bits_t bigint_bits = 4000;
|
||||||
constexpr limb_t bigint_limbs = bigint_bits / limb_bits;
|
constexpr limb_t bigint_limbs = bigint_bits / limb_bits;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ constexpr limb_t bigint_limbs = bigint_bits / limb_bits;
|
|||||||
template <limb_t size> struct stackvec {
|
template <limb_t size> struct stackvec {
|
||||||
limb data[size];
|
limb data[size];
|
||||||
// we never need more than 150 limbs
|
// we never need more than 150 limbs
|
||||||
uint8_t length{0};
|
uint_fast8_t length{0};
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
|
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
|
||||||
stackvec(stackvec const &) = delete;
|
stackvec(stackvec const &) = delete;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ constexpr static uint64_t powers_of_ten_uint64[] = {1UL,
|
|||||||
// effect on performance: in order to have a faster algorithm, we'd need
|
// effect on performance: in order to have a faster algorithm, we'd need
|
||||||
// to slow down performance for faster algorithms, and this is still fast.
|
// to slow down performance for faster algorithms, and this is still fast.
|
||||||
template <typename UC>
|
template <typename UC>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int16_t
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int_fast16_t
|
||||||
scientific_exponent(parsed_number_string_t<UC> const &num) noexcept {
|
scientific_exponent(parsed_number_string_t<UC> const &num) noexcept {
|
||||||
am_mant_t mantissa = num.mantissa;
|
am_mant_t mantissa = num.mantissa;
|
||||||
am_pow_t exponent = num.exponent;
|
am_pow_t exponent = num.exponent;
|
||||||
@ -116,7 +116,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am,
|
|||||||
if (-am.power2 >= mantissa_shift) {
|
if (-am.power2 >= mantissa_shift) {
|
||||||
// have a denormal float
|
// have a denormal float
|
||||||
am_pow_t shift = -am.power2 + 1;
|
am_pow_t shift = -am.power2 + 1;
|
||||||
cb(am, std::min<int16_t>(shift, 64));
|
cb(am, std::min<int_fast16_t>(shift, 64));
|
||||||
// check for round-up: if rounding-nearest carried us to the hidden bit.
|
// check for round-up: if rounding-nearest carried us to the hidden bit.
|
||||||
am.power2 = (am.mantissa <
|
am.power2 = (am.mantissa <
|
||||||
(am_mant_t(1) << binary_format<T>::mantissa_explicit_bits()))
|
(am_mant_t(1) << binary_format<T>::mantissa_explicit_bits()))
|
||||||
|
|||||||
@ -34,12 +34,12 @@
|
|||||||
namespace fast_float {
|
namespace fast_float {
|
||||||
|
|
||||||
// The number of digits in the mantissa.
|
// The number of digits in the mantissa.
|
||||||
typedef uint16_t am_digits;
|
typedef uint_fast16_t am_digits;
|
||||||
|
|
||||||
// The number of bits in the limb.
|
// The number of bits in the limb.
|
||||||
typedef uint8_t limb_t;
|
typedef uint_fast8_t limb_t;
|
||||||
|
|
||||||
typedef uint8_t chars_format_t;
|
typedef uint_fast8_t chars_format_t;
|
||||||
|
|
||||||
enum class chars_format : chars_format_t;
|
enum class chars_format : chars_format_t;
|
||||||
|
|
||||||
@ -444,13 +444,13 @@ full_multiplication(uint64_t a, uint64_t b) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Value of the mantissa.
|
// Value of the mantissa.
|
||||||
typedef uint64_t am_mant_t;
|
typedef uint_fast64_t am_mant_t;
|
||||||
// Size of bits in the mantissa.
|
// Size of bits in the mantissa.
|
||||||
typedef uint8_t am_bits_t;
|
typedef uint_fast8_t am_bits_t;
|
||||||
|
|
||||||
// Power bias is signed for handling a denormal float
|
// Power bias is signed for handling a denormal float
|
||||||
// or an invalid mantissa.
|
// or an invalid mantissa.
|
||||||
typedef int16_t am_pow_t;
|
typedef int_fast16_t am_pow_t;
|
||||||
|
|
||||||
// Bias so we can get the real exponent with an invalid adjusted_mantissa.
|
// Bias so we can get the real exponent with an invalid adjusted_mantissa.
|
||||||
constexpr static am_pow_t invalid_am_bias = -0x8000;
|
constexpr static am_pow_t invalid_am_bias = -0x8000;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user