Skip to content

Commit e777f8d

Browse files
committed
Fix bias
1 parent a80494a commit e777f8d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

include/boost/decimal/decimal32.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,13 +1483,16 @@ constexpr auto decimal32::to_components() const noexcept -> detail::decimal32_co
14831483
expval = UINT32_C(0b01000000);
14841484
significand |= (bits_ & detail::d32_comb_00_01_10_significand_bits) >> detail::d32_exponent_bits;
14851485
break;
1486+
case 0U:
1487+
significand |= (bits_ & detail::d32_comb_00_01_10_significand_bits) >> detail::d32_exponent_bits;
1488+
break;
14861489
}
14871490

14881491
significand |= (bits_ & detail::d32_significand_mask);
14891492
expval |= (bits_ & detail::d32_exponent_mask) >> detail::d32_significand_bits;
14901493

14911494
components.sig = significand;
1492-
components.exp = expval;
1495+
components.exp = expval - detail::bias_v<decimal32>;
14931496
components.sign = bits_ & detail::d32_sign_mask;
14941497

14951498
return components;

include/boost/decimal/gcc_decimal32.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ inline auto gcc_decimal32::to_components() const noexcept -> detail::decimal32_c
344344
}
345345

346346
components.sig = significand;
347-
components.exp = expval;
347+
components.exp = expval - detail::bias_v<decimal32>;
348348
components.sign = bits_ & detail::gccd32_sign_mask;
349349

350350
return components;

0 commit comments

Comments
 (0)