mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-02-07 02:09:52 +08:00
type usage fixes.
This commit is contained in:
parent
8f49511980
commit
489703f99d
@ -19,7 +19,7 @@ namespace fast_float {
|
|||||||
//
|
//
|
||||||
template <limb_t bit_precision>
|
template <limb_t bit_precision>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
|
||||||
compute_product_approximation(int64_t q, uint64_t w) noexcept {
|
compute_product_approximation(am_pow_t q, am_mant_t w) noexcept {
|
||||||
am_pow_t const index = 2 * am_pow_t(q - powers::smallest_power_of_five);
|
am_pow_t const index = 2 * am_pow_t(q - powers::smallest_power_of_five);
|
||||||
// For small values of q, e.g., q in [0,27], the answer is always exact
|
// For small values of q, e.g., q in [0,27], the answer is always exact
|
||||||
// because The line value128 firstproduct = full_multiplication(w,
|
// because The line value128 firstproduct = full_multiplication(w,
|
||||||
@ -71,14 +71,13 @@ constexpr fastfloat_really_inline am_pow_t power(am_pow_t q) noexcept {
|
|||||||
// for significant digits already multiplied by 10 ** q.
|
// for significant digits already multiplied by 10 ** q.
|
||||||
template <typename binary>
|
template <typename binary>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 adjusted_mantissa
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 adjusted_mantissa
|
||||||
compute_error_scaled(int64_t q, uint64_t w, am_digits lz) noexcept {
|
compute_error_scaled(am_pow_t q, am_mant_t w, am_digits lz) noexcept {
|
||||||
auto const hilz = static_cast<am_digits>((w >> 63) ^ 1);
|
auto const hilz = static_cast<am_pow_t>((w >> 63) ^ 1);
|
||||||
adjusted_mantissa answer;
|
adjusted_mantissa answer;
|
||||||
answer.mantissa = w << hilz;
|
answer.mantissa = w << hilz;
|
||||||
constexpr am_pow_t bias =
|
constexpr am_pow_t bias =
|
||||||
binary::mantissa_explicit_bits() - binary::minimum_exponent();
|
binary::mantissa_explicit_bits() - binary::minimum_exponent();
|
||||||
answer.power2 = am_pow_t(detail::power(am_pow_t(q)) + bias - hilz - lz - 62 +
|
answer.power2 = detail::power(q) + bias - hilz - lz - 62 + invalid_am_bias;
|
||||||
invalid_am_bias);
|
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ compute_error_scaled(int64_t q, uint64_t w, am_digits lz) noexcept {
|
|||||||
// the power2 in the exponent will be adjusted by invalid_am_bias.
|
// the power2 in the exponent will be adjusted by invalid_am_bias.
|
||||||
template <typename binary>
|
template <typename binary>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa
|
||||||
compute_error(int64_t q, uint64_t w) noexcept {
|
compute_error(am_pow_t q, am_mant_t w) noexcept {
|
||||||
am_digits const lz = leading_zeroes(w);
|
am_digits const lz = leading_zeroes(w);
|
||||||
w <<= lz;
|
w <<= lz;
|
||||||
value128 product =
|
value128 product =
|
||||||
@ -101,7 +100,7 @@ compute_error(int64_t q, uint64_t w) noexcept {
|
|||||||
// should recompute in such cases.
|
// should recompute in such cases.
|
||||||
template <typename binary>
|
template <typename binary>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa
|
||||||
compute_float(int64_t q, uint64_t w) noexcept {
|
compute_float(am_pow_t q, am_mant_t w) noexcept {
|
||||||
adjusted_mantissa answer;
|
adjusted_mantissa answer;
|
||||||
if ((w == 0) || (q < binary::smallest_power_of_ten())) {
|
if ((w == 0) || (q < binary::smallest_power_of_ten())) {
|
||||||
answer.power2 = 0;
|
answer.power2 = 0;
|
||||||
@ -144,8 +143,7 @@ compute_float(int64_t q, uint64_t w) noexcept {
|
|||||||
|
|
||||||
answer.mantissa = product.high >> shift;
|
answer.mantissa = product.high >> shift;
|
||||||
|
|
||||||
answer.power2 = am_pow_t(detail::power(am_pow_t(q)) + upperbit - lz -
|
answer.power2 = detail::power(q) + upperbit - lz - binary::minimum_exponent();
|
||||||
binary::minimum_exponent());
|
|
||||||
if (answer.power2 <= 0) { // we have a subnormal or very small value.
|
if (answer.power2 <= 0) { // we have a subnormal or very small value.
|
||||||
// Here have that answer.power2 <= 0 so -answer.power2 >= 0
|
// Here have that answer.power2 <= 0 so -answer.power2 >= 0
|
||||||
if (-answer.power2 + 1 >=
|
if (-answer.power2 + 1 >=
|
||||||
|
|||||||
@ -76,8 +76,8 @@ to_extended(T const value) noexcept {
|
|||||||
am.mantissa = bits & mantissa_mask;
|
am.mantissa = bits & mantissa_mask;
|
||||||
} else {
|
} else {
|
||||||
// normal
|
// normal
|
||||||
am.power2 = am_pow_t((bits & exponent_mask) >>
|
am.power2 = static_cast<am_pow_t>(bits & exponent_mask) >>
|
||||||
binary_format<T>::mantissa_explicit_bits());
|
binary_format<T>::mantissa_explicit_bits();
|
||||||
am.power2 -= bias;
|
am.power2 -= bias;
|
||||||
am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
|
am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user