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:
parent
350c98ab4d
commit
d3189acaa6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user