Skip to content

Commit 8080603

Browse files
committed
Default mem values
1 parent 1a021fa commit 8080603

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class decimal32_fast final
3131
// In regular decimal32 we have to decode the 24 bits of the significand and the 8 bits of the exp
3232
// Here we just use them directly at the cost of 2 extra bytes of internal state
3333

34-
std::uint32_t significand_;
35-
std::uint8_t exponent_;
36-
bool sign_;
34+
std::uint32_t significand_ {};
35+
std::uint8_t exponent_ {};
36+
bool sign_ {};
3737

3838
constexpr auto isneg() const noexcept -> bool
3939
{
@@ -159,19 +159,8 @@ class decimal32_fast final
159159
friend constexpr auto direct_init(std::uint32_t significand, std::uint8_t exponent, bool sign) noexcept -> decimal32_fast;
160160
};
161161

162-
constexpr auto direct_init(std::uint32_t significand, std::uint8_t exponent, bool sign = false) noexcept -> decimal32_fast
163-
{
164-
decimal32_fast val {};
165-
val.significand_ = significand;
166-
val.exponent_ = exponent;
167-
val.sign_ = sign;
168-
169-
return val;
170-
}
171-
172162
template <typename T1, typename T2, std::enable_if_t<detail::is_integral_v<T1> && detail::is_integral_v<T2>, bool>>
173163
constexpr decimal32_fast::decimal32_fast(T1 coeff, T2 exp, bool sign) noexcept
174-
: significand_ {}, exponent_ {}, sign_ {}
175164
{
176165
using Unsigned_Integer = detail::make_unsigned_t<T1>;
177166

@@ -215,7 +204,7 @@ template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, boo
215204
constexpr decimal32_fast::decimal32_fast(Integer val) noexcept
216205
{
217206
using ConversionType = std::conditional_t<std::is_same<Integer, bool>::value, std::int32_t, Integer>;
218-
*this = decimal32_fast{static_cast<ConversionType>(val), 0};
207+
*this = decimal32_fast{static_cast<ConversionType>(val), 0, false};
219208
}
220209

221210
#if defined(__clang__)
@@ -250,6 +239,16 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_fast::decimal32_fast(Float val) noexcept
250239
# pragma GCC diagnostic pop
251240
#endif
252241

242+
constexpr auto direct_init(std::uint32_t significand, std::uint8_t exponent, bool sign = false) noexcept -> decimal32_fast
243+
{
244+
decimal32_fast val;
245+
val.significand_ = significand;
246+
val.exponent_ = exponent;
247+
val.sign_ = sign;
248+
249+
return val;
250+
}
251+
253252
constexpr auto signbit(decimal32_fast val) noexcept -> bool
254253
{
255254
return val.sign_;

0 commit comments

Comments
 (0)