units
Use physical dimensions at compile-time or run-time.
common-denom-test.cpp
Go to the documentation of this file.
1 /// @file test/common-denom-test.cpp
2 /// @brief Test-case for vnix::common_denom_params.
3 /// @copyright 2019 Thomas E. Vaughan; all rights reserved.
4 /// @license BSD three-clause; see LICENSE.
5 
6 #include "../vnix/rat.hpp"
7 #include "catch.hpp"
8 
9 using namespace vnix::rat;
10 
11 
12 TEST_CASE("Number of bits is properly clamped.", "[common-denom-params]") {
13  rational<36, 28> r1(3,4);
14  rational<28, 36> r2(11,12);
15  auto cdp = common_denom(r1, r2);
16  using CDP = decltype(cdp);
17  REQUIRE(CDP::LCD_BITS == 64);
18  REQUIRE(CDP::N1_BITS == 64);
19  REQUIRE(CDP::N2_BITS == 56);
20 }
constexpr common_denom_params< NB1, DB1, NB2, DB2 > common_denom(rational< NB1, DB1 > r1, rational< NB2, DB2 > r2)
Compute least common denominator and corresponding numerators for the comparison of a pair of rationa...
constexpr rational(stype n=0, stype d=1)
Initialize from numerator and denominator.
Definition: rational.hpp:47
Thomas E. Vaughan&#39;s public software.
Definition: rational.hpp:13
Model of a fixed-precision rational number.
Definition: rational.hpp:27
Classes and functions supporting a model of a fixed-precision rational number.
Definition: rational.hpp:17