Skip to content

Commit 4a5b7c7

Browse files
authored
Merge pull request #948 from cppalliance/947
Replace internal fast types with fixed types
2 parents 4b4f25f + 5e5ee82 commit 4a5b7c7

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

include/boost/decimal/decimal128_fast.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
4444
{
4545
public:
4646
using significand_type = int128::uint128_t;
47-
using exponent_type = std::uint_fast32_t;
48-
using biased_exponent_type = std::int_fast32_t;
47+
using exponent_type = std::uint32_t;
48+
using biased_exponent_type = std::int32_t;
4949

5050
private:
5151
// Instead of having to encode and decode at every operation

include/boost/decimal/decimal32_fast.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ namespace decimal {
2929

3030
namespace detail {
3131

32-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_inf = std::numeric_limits<std::uint_fast32_t>::max() - 3;
33-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_qnan = std::numeric_limits<std::uint_fast32_t>::max() - 2;
34-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_snan = std::numeric_limits<std::uint_fast32_t>::max() - 1;
32+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_inf = std::numeric_limits<std::uint32_t>::max() - 3;
33+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_qnan = std::numeric_limits<std::uint32_t>::max() - 2;
34+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d32_fast_snan = std::numeric_limits<std::uint32_t>::max() - 1;
3535

3636
}
3737

3838
BOOST_DECIMAL_EXPORT class decimal_fast32_t final
3939
{
4040
public:
41-
using significand_type = std::uint_fast32_t;
42-
using exponent_type = std::uint_fast8_t;
43-
using biased_exponent_type = std::int_fast32_t;
41+
using significand_type = std::uint32_t;
42+
using exponent_type = std::uint8_t;
43+
using biased_exponent_type = std::int32_t;
4444

4545
private:
4646
// In regular decimal32_t we have to decode the 24 bits of the significand and the 8 bits of the exp
@@ -348,7 +348,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
348348
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE Decimal, std::enable_if_t<detail::is_decimal_floating_point_v<Decimal> && (detail::decimal_val_v<Decimal> <= detail::decimal_val_v<decimal_fast32_t>), bool> = true>
349349
explicit constexpr operator Decimal() const noexcept;
350350

351-
friend constexpr auto direct_init(std::uint_fast32_t significand, std::uint_fast8_t exponent, bool sign) noexcept -> decimal_fast32_t;
351+
friend constexpr auto direct_init(significand_type significand, exponent_type exponent, bool sign) noexcept -> decimal_fast32_t;
352352
friend constexpr auto direct_init(const detail::decimal_fast32_t_components& x) noexcept -> decimal_fast32_t;
353353

354354
// <cmath> or extensions that need to be friends
@@ -452,7 +452,7 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t::decimal_fast32_t(Float val) noex
452452
# pragma GCC diagnostic pop
453453
#endif
454454

455-
constexpr auto direct_init(std::uint_fast32_t significand, std::uint_fast8_t exponent, bool sign = false) noexcept -> decimal_fast32_t
455+
constexpr auto direct_init(const decimal_fast32_t::significand_type significand, const decimal_fast32_t::exponent_type exponent, const bool sign = false) noexcept -> decimal_fast32_t
456456
{
457457
decimal_fast32_t val;
458458
val.significand_ = significand;
@@ -1474,7 +1474,7 @@ struct numeric_limits<boost::decimal::decimal_fast32_t>
14741474
static constexpr int min_exponent10 = min_exponent;
14751475
static constexpr int max_exponent = 96;
14761476
static constexpr int max_exponent10 = max_exponent;
1477-
static constexpr bool traps = numeric_limits<std::uint_fast32_t>::traps;
1477+
static constexpr bool traps = numeric_limits<std::uint32_t>::traps;
14781478
static constexpr bool tinyness_before = true;
14791479

14801480
// Member functions

include/boost/decimal/decimal64_fast.hpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <boost/decimal/detail/ryu/ryu_generic_128.hpp>
2020
#include <boost/decimal/detail/promotion.hpp>
2121
#include <boost/decimal/detail/cmath/next.hpp>
22+
#include <boost/decimal/detail/components.hpp>
2223

2324
#ifndef BOOST_DECIMAL_BUILD_MODULE
2425

@@ -32,28 +33,18 @@ namespace decimal {
3233

3334
namespace detail {
3435

35-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits<std::uint_fast64_t>::max() - 3;
36-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits<std::uint_fast64_t>::max() - 2;
37-
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits<std::uint_fast64_t>::max() - 1;
38-
39-
struct decimal_fast64_t_components
40-
{
41-
using significand_type = std::uint_fast64_t;
42-
using biased_exponent_type = std::int_fast32_t;
43-
44-
significand_type sig;
45-
biased_exponent_type exp;
46-
bool sign;
47-
};
36+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits<std::uint64_t>::max() - 3;
37+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits<std::uint64_t>::max() - 2;
38+
BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits<std::uint64_t>::max() - 1;
4839

4940
} // namespace detail
5041

5142
BOOST_DECIMAL_EXPORT class decimal_fast64_t final
5243
{
5344
public:
54-
using significand_type = std::uint_fast64_t;
55-
using exponent_type = std::uint_fast16_t;
56-
using biased_exponent_type = std::int_fast32_t;
45+
using significand_type = std::uint64_t;
46+
using exponent_type = std::uint16_t;
47+
using biased_exponent_type = std::int32_t;
5748

5849
private:
5950
// In regular decimal64_t we have to decode the significand end exponent
@@ -1384,7 +1375,7 @@ struct numeric_limits<boost::decimal::decimal_fast64_t>
13841375
static constexpr int min_exponent10 = min_exponent;
13851376
static constexpr int max_exponent = 384;
13861377
static constexpr int max_exponent10 = max_exponent;
1387-
static constexpr bool traps = numeric_limits<std::uint_fast64_t>::traps;
1378+
static constexpr bool traps = numeric_limits<std::uint64_t>::traps;
13881379
static constexpr bool tinyness_before = true;
13891380

13901381
// Member functions

include/boost/decimal/detail/components.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ struct decimal_components
5353

5454
using decimal32_t_components = impl::decimal_components<std::uint32_t, std::int32_t>;
5555

56-
using decimal_fast32_t_components = impl::decimal_components<std::uint_fast32_t, std::int_fast32_t>;
56+
using decimal_fast32_t_components = impl::decimal_components<std::uint32_t, std::int32_t>;
5757

5858
using decimal64_t_components = impl::decimal_components<std::uint64_t, std::int32_t>;
5959

60+
using decimal_fast64_t_components = impl::decimal_components<std::uint64_t, std::int32_t>;
61+
6062
using decimal128_t_components = impl::decimal_components<boost::int128::uint128_t, std::int32_t>;
6163

62-
using decimal_fast128_t_components = impl::decimal_components<boost::int128::uint128_t, std::int_fast32_t>;
64+
using decimal_fast128_t_components = impl::decimal_components<boost::int128::uint128_t, std::int32_t>;
6365

6466
} // namespace detail
6567
} // namespace decimal

0 commit comments

Comments
 (0)