employing more mathemtaically correct ratio_gcd calc (for common ratio)

really finds the maximum common ration as opposed to previous algo which
simplified on the exp part of the ratio by using std::min
most of new code credit to Conor Williams
discussion and additional doc here:
https://github.com/mpusz/units/issues/62#issuecomment-588152833
test case was 1yd + 1in = 37in => added as a test
commenting out unusued ratio_add and its tests
if to be reintroduced, should also use the new gcd routines
additonal change was required to check in `safe_divisible` concept
den=1 is not sufficient anymore. reusing new gcd routines
moved ratio nomalize and new gcd routines into new, separate bits/ratio_maths.h
this resolves #62
This commit is contained in:
Oliver Schönrock
2020-02-20 19:59:12 +01:00
committed by Mateusz Pusz
parent 1280b7d4be
commit 39a2c2de0e
5 changed files with 248 additions and 83 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ concept safe_convertible = // exposition only
template<typename Rep, typename UnitFrom, typename UnitTo>
concept safe_divisible = // exposition only
treat_as_floating_point<Rep> ||
ratio_divide<typename UnitFrom::ratio, typename UnitTo::ratio>::den == 1;
ratio_divide<typename UnitFrom::ratio, typename UnitTo::ratio>::is_integral();
} // namespace detail