- Test:
- cover some aspects of working with fractional numbers.
Definition at line 54 of file rational-test.cpp.
◆ demonstrate_basics()
void demonstrate_basics |
( |
| ) |
|
|
inlineprivate |
- Test:
- demonstrate fundamental properties of rational arithmetics as provided by boost::rational
- represent rational fractions precisely
- convert to other types and then perform the division
- our typedef
Rat = boost::rational<int64_t>
- our user-defined literal "_r" to simplify notation
- string conversion to reveal numerator and denominator
- automatic normalisation and reduction
- some typical fractional calculation examples.
Definition at line 79 of file rational-test.cpp.
◆ verify_limits()
- Test:
- demonstrate the limits and perils of rational fractions
- largest and smallest number representable
- numeric overflow due to normalisation
- predicates to check for possible trouble
Definition at line 110 of file rational-test.cpp.
◆ verify_intLog2()
- Test:
- an optimised implementation of integer binary logarithm
- basically finds the highest bit which is set
- can be used with various integral types
- performs better than using the floating-point solution
- Todo:
- this test (and the implementation) belongs into some basic util header.
Definition at line 199 of file rational-test.cpp.
References util::ilog2().
◆ verify_requant()
- Test:
- helper to re-quantise a rational fraction
- recast a number in terms of another denominator
- this introduces an error of known limited size
- and is an option to work around "poisonous" fractions
Definition at line 331 of file rational-test.cpp.
References MAX.
The documentation for this class was generated from the following file: