File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1111
1212#ifndef BOOST_DECIMAL_BUILD_MODULE
1313#include < cstdint>
14+ #include < limits>
1415#endif
1516
1617namespace boost {
@@ -427,6 +428,24 @@ template <typename DecimalType = decimal32_fast>
427428constexpr auto from_dpd_d32 (std::uint32_t dpd) noexcept
428429 BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, DecimalType)
429430{
431+ // First we check for non-finite values
432+ // Since they are in the same initial format as BID it's easy to check with our existing masks
433+ if ((dpd & detail::d32_inf_mask) == detail::d32_inf_mask)
434+ {
435+ if ((dpd & detail::d32_snan_mask) == detail::d32_snan_mask)
436+ {
437+ return std::numeric_limits<DecimalType>::signaling_NaN ();
438+ }
439+ else if ((dpd & detail::d32_nan_mask) == detail::d32_nan_mask)
440+ {
441+ return std::numeric_limits<DecimalType>::quiet_NaN ();
442+ }
443+ else
444+ {
445+ return std::numeric_limits<DecimalType>::infinity ();
446+ }
447+ }
448+
430449 // The bit lengths are the same as used in the standard bid format
431450 const auto sign {(dpd & detail::d32_sign_mask) != 0 };
432451 const auto combination_field_bits {(dpd & detail::d32_combination_field_mask) >> 26U };
You can’t perform that action at this time.
0 commit comments