Skip to content

Commit

Permalink
Merge pull request #286 from hvdijk/avoid-fma-ub
Browse files Browse the repository at this point in the history
Avoid undefined behavior in FMA.
  • Loading branch information
hvdijk authored Jan 9, 2024
2 parents ce793d3 + 14ed452 commit 400c4cb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ T ABACUS_API __abacus_fma_unsafe(const T x, const T y, const T z) {
const SignedType finalExpBiased =
(((ansAsUint & exp_mask) >> mantissa_bits)) + 2 * ansExp;

if (finalExpBiased < 1) {
if (ans != 0 && finalExpBiased < 1) {
// The answer is a denormal, find what bits will be cut off and see if it's
// going to result in a RTE case.
const UnsignedType rounding_bits = UnsignedType(0x1)
Expand Down

0 comments on commit 400c4cb

Please sign in to comment.