Skip to content

Commit

Permalink
fix edge cases in sgn function
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Jan 7, 2025
1 parent 68a78da commit 3e99d93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/units/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,10 @@ template <isQuantity Q, isQuantity R> constexpr Q min(const Q& lhs, const R& rhs
return (lhs < rhs ? lhs : rhs);
}

template <isQuantity Q> constexpr int sgn(const Q& lhs) {
return (lhs.internal() > 0) ? 1 : (lhs.internal() < 0 ? -1 : 0);
template <isQuantity Q> constexpr double sgn(const Q& lhs) {
if (lhs.internal() > 0) return 1;
if (lhs.internal() < 0) return -1;
return lhs.internal();
}

template <int R, isQuantity Q, isQuantity S = Exponentiated<Q, std::ratio<R>>> constexpr S pow(const Q& lhs) {
Expand Down

0 comments on commit 3e99d93

Please sign in to comment.