1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Add a constexpr route that explicitly calculates the simplest possible form.

This commit is contained in:
Thomas Harte 2022-01-01 17:14:52 -05:00
parent 350c98ab4d
commit d3189acaa6

View File

@ -33,6 +33,10 @@ struct Time {
Time(float value) {
install_float(value);
}
static constexpr Time simplified(unsigned int _length, unsigned int _clock_rate) {
const auto gcd = std::gcd(_length, _clock_rate);
return Time(_length / gcd, _clock_rate / gcd);
}
/*!
Reduces this @c Time to its simplest form; eliminates all common factors from @c length