Skip to content

Commit e124635

Browse files
committed
added lacking overloads to avoid potential ambiguity
1 parent 6702cd4 commit e124635

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/fast_float/parse_number.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ integer_times_pow10(int64_t mantissa, int decimal_exponent) noexcept {
373373

374374
// the following overloads are here to avoid surprising ambiguity for int,
375375
// unsigned, etc.
376+
#if !defined(_MSC_VER)
377+
FASTFLOAT_CONSTEXPR20 inline double
378+
integer_times_pow10(unsigned long long mantissa,
379+
int decimal_exponent) noexcept {
380+
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
381+
}
382+
383+
FASTFLOAT_CONSTEXPR20 inline double
384+
integer_times_pow10(long long mantissa, int decimal_exponent) noexcept {
385+
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
386+
}
387+
#endif
376388
FASTFLOAT_CONSTEXPR20 inline double
377389
integer_times_pow10(unsigned mantissa, int decimal_exponent) noexcept {
378390
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);

tests/basictest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,10 @@ TEST_CASE("integer_times_pow10") {
21402140
-3141592653589793238, -18, -3.141592653589793238);
21412141
verify_integer_multiplication_by_power_of_10<uint64_t>(
21422142
3141592653589793238, -18, 3.141592653589793238);
2143+
verify_integer_multiplication_by_power_of_10<long long>(
2144+
-3141592653589793238, -18, -3.141592653589793238);
2145+
verify_integer_multiplication_by_power_of_10<unsigned long long>(
2146+
3141592653589793238, -18, 3.141592653589793238);
21432147

21442148
for (int mode : {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO, FE_TONEAREST}) {
21452149
fesetround(mode);

0 commit comments

Comments
 (0)