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
@@ -170,4 +170,9 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
{
CHECK(fmt::format("{}", 1q_Npm) == "1 N/m");
}
SECTION("addition with common ratio")
{
CHECK(fmt::format("{}", 1q_in + 1q_yd) == "37 in");
}
}