Fix abs(fixed_point), lmao
This commit is contained in:
parent
615ee51229
commit
64ffe27c2a
1 changed files with 1 additions and 2 deletions
|
|
@ -337,9 +337,8 @@ namespace psemek::util
|
||||||
constexpr fixed_point<I, F, S> abs(fixed_point<I, F, S> x)
|
constexpr fixed_point<I, F, S> abs(fixed_point<I, F, S> x)
|
||||||
{
|
{
|
||||||
using FP = fixed_point<I, F, S>;
|
using FP = fixed_point<I, F, S>;
|
||||||
using rep_type = typename FP::rep_type;
|
|
||||||
if constexpr (S)
|
if constexpr (S)
|
||||||
return FP::from_rep(x.rep() & ~(static_cast<rep_type>(1) << (I + F - 1)));
|
return FP::from_rep(std::abs(x.rep()));
|
||||||
else
|
else
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue