Skip to content

Commit

Permalink
Use fabs in fnearest
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Oct 14, 2020
1 parent a68cd75 commit 532dbba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ T fnearest(T value) noexcept

// This implementation is based on adjusting the result produced by trunc() by +-1 when needed.
const auto t = std::trunc(value);
if (const auto diff = std::abs(value - t); diff > T{0.5} || (diff == T{0.5} && !is_even(t)))
if (const auto diff = fabs(value - t); diff > T{0.5} || (diff == T{0.5} && !is_even(t)))
return t + fcopysign(T{1}, value);
else
return t;
Expand Down

0 comments on commit 532dbba

Please sign in to comment.