Skip to content

Commit fcdb586

Browse files
committed
cleanup in the API.
1 parent cd61547 commit fcdb586

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

include/fast_float/fast_float.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ from_chars_advanced(UC const *first, UC const *last, T &value,
6060
*/
6161
FASTFLOAT_CONSTEXPR20 inline double
6262
integer_times_pow10(uint64_t const mantissa,
63-
am_pow_t const decimal_exponent) noexcept;
63+
int const decimal_exponent) noexcept;
6464
FASTFLOAT_CONSTEXPR20 inline double
6565
integer_times_pow10(int64_t const mantissa,
66-
am_pow_t const decimal_exponent) noexcept;
66+
int const decimal_exponent) noexcept;
6767

6868
/**
6969
* This function is a template overload of `integer_times_pow10()`
@@ -74,12 +74,12 @@ template <typename T>
7474
FASTFLOAT_CONSTEXPR20
7575
typename std::enable_if<is_supported_float_type<T>::value, T>::type
7676
integer_times_pow10(uint64_t const mantissa,
77-
am_pow_t const decimal_exponent) noexcept;
77+
int const decimal_exponent) noexcept;
7878
template <typename T>
7979
FASTFLOAT_CONSTEXPR20
8080
typename std::enable_if<is_supported_float_type<T>::value, T>::type
8181
integer_times_pow10(int64_t const mantissa,
82-
am_pow_t const decimal_exponent) noexcept;
82+
int const decimal_exponent) noexcept;
8383

8484
/**
8585
* from_chars for integer types.
@@ -88,7 +88,7 @@ template <typename T, typename UC = char,
8888
typename = FASTFLOAT_ENABLE_IF(is_supported_integer_type<T>::value)>
8989
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
9090
from_chars(UC const *first, UC const *last, T &value,
91-
base_t const base = 10) noexcept;
91+
int const base = 10) noexcept;
9292

9393
} // namespace fast_float
9494

include/fast_float/parse_number.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -376,33 +376,33 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
376376

377377
template <typename T, typename UC, typename>
378378
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
379-
from_chars(UC const *first, UC const *last, T &value,
380-
base_t const base) noexcept {
379+
from_chars(UC const *first, UC const *last, T &value, int const base) noexcept {
381380

382381
static_assert(is_supported_integer_type<T>::value,
383382
"only integer types are supported");
384383
static_assert(is_supported_char_type<UC>::value,
385384
"only char, wchar_t, char16_t and char32_t are supported");
386385

387-
parse_options_t<UC> const options(chars_format::general, UC('.'), base);
386+
parse_options_t<UC> const options(chars_format::general, UC('.'),
387+
static_cast<base_t>(base));
388388
return from_chars_advanced(first, last, value, options);
389389
}
390390

391391
template <typename T>
392392
FASTFLOAT_CONSTEXPR20
393393
typename std::enable_if<is_supported_float_type<T>::value, T>::type
394394
integer_times_pow10(uint64_t const mantissa,
395-
am_pow_t const decimal_exponent) noexcept {
395+
int const decimal_exponent) noexcept {
396396
T value;
397-
if (clinger_fast_path_impl(mantissa, decimal_exponent,
397+
const auto exponent = static_cast<am_pow_t>(decimal_exponent);
398+
if (clinger_fast_path_impl(mantissa, exponent,
398399
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
399400
false,
400401
#endif
401402
value))
402403
return value;
403404

404-
adjusted_mantissa am =
405-
compute_float<binary_format<T>>(decimal_exponent, mantissa);
405+
adjusted_mantissa am = compute_float<binary_format<T>>(exponent, mantissa);
406406
to_float(
407407
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
408408
false,
@@ -415,24 +415,25 @@ template <typename T>
415415
FASTFLOAT_CONSTEXPR20
416416
typename std::enable_if<is_supported_float_type<T>::value, T>::type
417417
integer_times_pow10(int64_t const mantissa,
418-
am_pow_t const decimal_exponent) noexcept {
418+
int const decimal_exponent) noexcept {
419419
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
420420
const auto is_negative = mantissa < 0;
421421
const auto m = static_cast<am_mant_t>(is_negative ? -mantissa : mantissa);
422422
#else
423423
FASTFLOAT_ASSUME(mantissa >= 0);
424424
const auto m = static_cast<am_mant_t>(mantissa);
425425
#endif
426+
const auto exponent = static_cast<am_pow_t>(decimal_exponent);
426427
T value;
427-
if (clinger_fast_path_impl(m, decimal_exponent,
428+
if (clinger_fast_path_impl(m, exponent,
428429
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
429430
is_negative,
430431
#endif
431432
value))
432433
return value;
433434

434435
adjusted_mantissa const am =
435-
compute_float<binary_format<double>>(decimal_exponent, m);
436+
compute_float<binary_format<double>>(exponent, m);
436437

437438
to_float(
438439
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
@@ -444,13 +445,13 @@ FASTFLOAT_CONSTEXPR20
444445

445446
FASTFLOAT_CONSTEXPR20 inline double
446447
integer_times_pow10(uint64_t const mantissa,
447-
am_pow_t const decimal_exponent) noexcept {
448+
int const decimal_exponent) noexcept {
448449
return integer_times_pow10<double>(mantissa, decimal_exponent);
449450
}
450451

451452
FASTFLOAT_CONSTEXPR20 inline double
452453
integer_times_pow10(int64_t const mantissa,
453-
am_pow_t const decimal_exponent) noexcept {
454+
int const decimal_exponent) noexcept {
454455
return integer_times_pow10<double>(mantissa, decimal_exponent);
455456
}
456457

@@ -463,7 +464,7 @@ FASTFLOAT_CONSTEXPR20
463464
!std::is_signed<Int>::value,
464465
T>::type
465466
integer_times_pow10(Int const mantissa,
466-
am_pow_t const decimal_exponent) noexcept {
467+
int const decimal_exponent) noexcept {
467468
return integer_times_pow10<T>(static_cast<uint64_t>(mantissa),
468469
decimal_exponent);
469470
}
@@ -475,24 +476,22 @@ FASTFLOAT_CONSTEXPR20
475476
std::is_signed<Int>::value,
476477
T>::type
477478
integer_times_pow10(Int const mantissa,
478-
am_pow_t const decimal_exponent) noexcept {
479+
int const decimal_exponent) noexcept {
479480
return integer_times_pow10<T>(static_cast<int64_t>(mantissa),
480481
decimal_exponent);
481482
}
482483

483484
template <typename Int>
484485
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
485486
std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
486-
integer_times_pow10(Int const mantissa,
487-
am_pow_t const decimal_exponent) noexcept {
487+
integer_times_pow10(Int const mantissa, int const decimal_exponent) noexcept {
488488
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
489489
}
490490

491491
template <typename Int>
492492
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
493493
std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
494-
integer_times_pow10(Int const mantissa,
495-
am_pow_t const decimal_exponent) noexcept {
494+
integer_times_pow10(Int const mantissa, int const decimal_exponent) noexcept {
496495
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
497496
}
498497

0 commit comments

Comments
 (0)