mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
renamed the function, cleaned up return type
This commit is contained in:
parent
763558b9ac
commit
20a7383442
@ -58,16 +58,12 @@ from_chars_advanced(UC const *first, UC const *last, T &value,
|
|||||||
* The implementation does not throw and does not allocate memory (e.g., with
|
* The implementation does not throw and does not allocate memory (e.g., with
|
||||||
* `new` or `malloc`).
|
* `new` or `malloc`).
|
||||||
*/
|
*/
|
||||||
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
|
integer_times_pow10(uint64_t mantissa, int decimal_exponent) noexcept;
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
FASTFLOAT_CONSTEXPR20 inline
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
typename std::enable_if<is_supported_float_type<double>::value,
|
||||||
double>::type
|
double>::type
|
||||||
multiply_integer_and_power_of_10(uint64_t mantissa,
|
integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept;
|
||||||
int decimal_exponent) noexcept;
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
|
||||||
double>::type
|
|
||||||
multiply_integer_and_power_of_10(int64_t mantissa,
|
|
||||||
int decimal_exponent) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* from_chars for integer types.
|
* from_chars for integer types.
|
||||||
|
|||||||
@ -344,11 +344,8 @@ from_chars(UC const *first, UC const *last, T &value, int base) noexcept {
|
|||||||
return from_chars_advanced(first, last, value, options);
|
return from_chars_advanced(first, last, value, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
integer_times_pow10(uint64_t mantissa, int decimal_exponent) noexcept {
|
||||||
double>::type
|
|
||||||
multiply_integer_and_power_of_10(uint64_t mantissa,
|
|
||||||
int decimal_exponent) noexcept {
|
|
||||||
double value;
|
double value;
|
||||||
if (clinger_fast_path_impl(mantissa, decimal_exponent, false, value))
|
if (clinger_fast_path_impl(mantissa, decimal_exponent, false, value))
|
||||||
return value;
|
return value;
|
||||||
@ -359,11 +356,8 @@ FASTFLOAT_CONSTEXPR20 inline
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept {
|
||||||
double>::type
|
|
||||||
multiply_integer_and_power_of_10(int64_t mantissa,
|
|
||||||
int decimal_exponent) noexcept {
|
|
||||||
const bool is_negative = mantissa < 0;
|
const bool is_negative = mantissa < 0;
|
||||||
const uint64_t m = static_cast<uint64_t>(is_negative ? -mantissa : mantissa);
|
const uint64_t m = static_cast<uint64_t>(is_negative ? -mantissa : mantissa);
|
||||||
|
|
||||||
@ -379,22 +373,14 @@ FASTFLOAT_CONSTEXPR20 inline
|
|||||||
|
|
||||||
// the following overloads are here to avoid surprising ambiguity for int,
|
// the following overloads are here to avoid surprising ambiguity for int,
|
||||||
// unsigned, etc.
|
// unsigned, etc.
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
integer_times_pow10(unsigned mantissa, int decimal_exponent) noexcept {
|
||||||
double>::type
|
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
|
||||||
multiply_integer_and_power_of_10(unsigned mantissa,
|
|
||||||
int decimal_exponent) noexcept {
|
|
||||||
return multiply_integer_and_power_of_10(static_cast<uint64_t>(mantissa),
|
|
||||||
decimal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR20 inline
|
FASTFLOAT_CONSTEXPR20 inline double
|
||||||
typename std::enable_if<is_supported_float_type<double>::value,
|
integer_times_pow10(int mantissa, int decimal_exponent) noexcept {
|
||||||
double>::type
|
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
|
||||||
multiply_integer_and_power_of_10(int mantissa,
|
|
||||||
int decimal_exponent) noexcept {
|
|
||||||
return multiply_integer_and_power_of_10(static_cast<int64_t>(mantissa),
|
|
||||||
decimal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
|
|||||||
@ -2091,7 +2091,7 @@ void verify_integer_multiplication_by_power_of_10(Int mantissa,
|
|||||||
int decimal_exponent,
|
int decimal_exponent,
|
||||||
double expected) {
|
double expected) {
|
||||||
const double actual =
|
const double actual =
|
||||||
fast_float::multiply_integer_and_power_of_10(mantissa, decimal_exponent);
|
fast_float::integer_times_pow10(mantissa, decimal_exponent);
|
||||||
|
|
||||||
INFO("m * 10^e=" << mantissa << " * 10^" << decimal_exponent
|
INFO("m * 10^e=" << mantissa << " * 10^" << decimal_exponent
|
||||||
<< "\n"
|
<< "\n"
|
||||||
@ -2120,7 +2120,7 @@ void verify_integer_multiplication_by_power_of_10(Int mantissa,
|
|||||||
expected_result);
|
expected_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("multiply_integer_and_power_of_10") {
|
TEST_CASE("integer_times_pow10") {
|
||||||
// explicitly verifying API with different types of integers
|
// explicitly verifying API with different types of integers
|
||||||
verify_integer_multiplication_by_power_of_10<int8_t>(31, -1, 3.1);
|
verify_integer_multiplication_by_power_of_10<int8_t>(31, -1, 3.1);
|
||||||
verify_integer_multiplication_by_power_of_10<int8_t>(-31, -1, -3.1);
|
verify_integer_multiplication_by_power_of_10<int8_t>(-31, -1, -3.1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user