mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 17:26:51 +08:00
making constexpr as inline.
This commit is contained in:
parent
799f24ba07
commit
06e61729c9
@ -210,68 +210,68 @@ constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5,
|
||||
1e6, 1e7, 1e8, 1e9, 1e10};
|
||||
|
||||
template <typename T> struct binary_format {
|
||||
static constexpr int mantissa_explicit_bits();
|
||||
static constexpr int minimum_exponent();
|
||||
static constexpr int infinite_power();
|
||||
static constexpr int sign_index();
|
||||
static constexpr int min_exponent_fast_path();
|
||||
static constexpr int max_exponent_fast_path();
|
||||
static constexpr int max_exponent_round_to_even();
|
||||
static constexpr int min_exponent_round_to_even();
|
||||
static constexpr uint64_t max_mantissa_fast_path();
|
||||
static constexpr int largest_power_of_ten();
|
||||
static constexpr int smallest_power_of_ten();
|
||||
static constexpr T exact_power_of_ten(int64_t power);
|
||||
static inline constexpr int mantissa_explicit_bits();
|
||||
static inline constexpr int minimum_exponent();
|
||||
static inline constexpr int infinite_power();
|
||||
static inline constexpr int sign_index();
|
||||
static inline constexpr int min_exponent_fast_path();
|
||||
static inline constexpr int max_exponent_fast_path();
|
||||
static inline constexpr int max_exponent_round_to_even();
|
||||
static inline constexpr int min_exponent_round_to_even();
|
||||
static inline constexpr uint64_t max_mantissa_fast_path();
|
||||
static inline constexpr int largest_power_of_ten();
|
||||
static inline constexpr int smallest_power_of_ten();
|
||||
static inline constexpr T exact_power_of_ten(int64_t power);
|
||||
};
|
||||
|
||||
template <> constexpr int binary_format<double>::mantissa_explicit_bits() {
|
||||
template <> inline constexpr int binary_format<double>::mantissa_explicit_bits() {
|
||||
return 52;
|
||||
}
|
||||
template <> constexpr int binary_format<float>::mantissa_explicit_bits() {
|
||||
template <> inline constexpr int binary_format<float>::mantissa_explicit_bits() {
|
||||
return 23;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::max_exponent_round_to_even() {
|
||||
template <> inline constexpr int binary_format<double>::max_exponent_round_to_even() {
|
||||
return 23;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<float>::max_exponent_round_to_even() {
|
||||
template <> inline constexpr int binary_format<float>::max_exponent_round_to_even() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::min_exponent_round_to_even() {
|
||||
template <> inline constexpr int binary_format<double>::min_exponent_round_to_even() {
|
||||
return -4;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<float>::min_exponent_round_to_even() {
|
||||
template <> inline constexpr int binary_format<float>::min_exponent_round_to_even() {
|
||||
return -17;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::minimum_exponent() {
|
||||
template <> inline constexpr int binary_format<double>::minimum_exponent() {
|
||||
return -1023;
|
||||
}
|
||||
template <> constexpr int binary_format<float>::minimum_exponent() {
|
||||
template <> inline constexpr int binary_format<float>::minimum_exponent() {
|
||||
return -127;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::infinite_power() {
|
||||
template <> inline constexpr int binary_format<double>::infinite_power() {
|
||||
return 0x7FF;
|
||||
}
|
||||
template <> constexpr int binary_format<float>::infinite_power() {
|
||||
template <> inline constexpr int binary_format<float>::infinite_power() {
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::sign_index() { return 63; }
|
||||
template <> constexpr int binary_format<float>::sign_index() { return 31; }
|
||||
template <> inline constexpr int binary_format<double>::sign_index() { return 63; }
|
||||
template <> inline constexpr int binary_format<float>::sign_index() { return 31; }
|
||||
|
||||
template <> constexpr int binary_format<double>::min_exponent_fast_path() {
|
||||
template <> inline constexpr int binary_format<double>::min_exponent_fast_path() {
|
||||
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
|
||||
return 0;
|
||||
#else
|
||||
return -22;
|
||||
#endif
|
||||
}
|
||||
template <> constexpr int binary_format<float>::min_exponent_fast_path() {
|
||||
template <> inline constexpr int binary_format<float>::min_exponent_fast_path() {
|
||||
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
|
||||
return 0;
|
||||
#else
|
||||
@ -279,46 +279,46 @@ template <> constexpr int binary_format<float>::min_exponent_fast_path() {
|
||||
#endif
|
||||
}
|
||||
|
||||
template <> constexpr int binary_format<double>::max_exponent_fast_path() {
|
||||
template <> inline constexpr int binary_format<double>::max_exponent_fast_path() {
|
||||
return 22;
|
||||
}
|
||||
template <> constexpr int binary_format<float>::max_exponent_fast_path() {
|
||||
template <> inline constexpr int binary_format<float>::max_exponent_fast_path() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
template <> constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
|
||||
template <> inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
|
||||
return uint64_t(2) << mantissa_explicit_bits();
|
||||
}
|
||||
template <> constexpr uint64_t binary_format<float>::max_mantissa_fast_path() {
|
||||
template <> inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() {
|
||||
return uint64_t(2) << mantissa_explicit_bits();
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr double binary_format<double>::exact_power_of_ten(int64_t power) {
|
||||
inline constexpr double binary_format<double>::exact_power_of_ten(int64_t power) {
|
||||
return powers_of_ten_double[power];
|
||||
}
|
||||
template <>
|
||||
constexpr float binary_format<float>::exact_power_of_ten(int64_t power) {
|
||||
inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) {
|
||||
|
||||
return powers_of_ten_float[power];
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
constexpr int binary_format<double>::largest_power_of_ten() {
|
||||
inline constexpr int binary_format<double>::largest_power_of_ten() {
|
||||
return 308;
|
||||
}
|
||||
template <>
|
||||
constexpr int binary_format<float>::largest_power_of_ten() {
|
||||
inline constexpr int binary_format<float>::largest_power_of_ten() {
|
||||
return 38;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr int binary_format<double>::smallest_power_of_ten() {
|
||||
inline constexpr int binary_format<double>::smallest_power_of_ten() {
|
||||
return -342;
|
||||
}
|
||||
template <>
|
||||
constexpr int binary_format<float>::smallest_power_of_ten() {
|
||||
inline constexpr int binary_format<float>::smallest_power_of_ten() {
|
||||
return -65;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user