forked from mpusz/mp-units
Handle exp explicitly in as_magnitude()
The new test actually passed without modifying the code. However, that might be implementation-dependent (presumably based on canonicalization of the `ratio` template parameter), so I wanted a more obviously correct implementation.
This commit is contained in:
@@ -333,7 +333,9 @@ constexpr auto operator/(Magnitude auto l, Magnitude auto r) { return l * pow<-1
|
||||
template<ratio R>
|
||||
requires (R.num > 0)
|
||||
constexpr Magnitude auto as_magnitude() {
|
||||
return detail::prime_factorization_v<R.num> / detail::prime_factorization_v<R.den>;
|
||||
return pow<R.exp>(detail::prime_factorization_v<10>)
|
||||
* detail::prime_factorization_v<R.num>
|
||||
/ detail::prime_factorization_v<R.den>;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
|
||||
Reference in New Issue
Block a user