Ratio maths fixed
This commit is contained in:
1 parent
5c98924efb
commit
72ed03fbf9
3 files changed
+15
-6
No files matched your search
@@ -313,7 +313,14 @@ struct quantity_cast_impl<To, CRatio, CRep, false, true, false> {
|
||||
template<typename Q1, typename Q2>
|
||||
constexpr ratio cast_ratio(const Q1& from, const Q2& to)
|
||||
{
|
||||
return quantity_ratio(from) / quantity_ratio(to);
|
||||
using FromU = Q1::unit;
|
||||
using ToU = Q2::unit;
|
||||
if constexpr(same_unit_reference<FromU, ToU>::value) {
|
||||
return FromU::ratio / ToU::ratio;
|
||||
}
|
||||
else {
|
||||
return quantity_ratio(from) / quantity_ratio(to);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
Reference in new issue
Block a user