1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-25 11:17:26 +00:00

Added ability to query how long since the new interval was set to the timed event loop. Discovered that LCM will returning the net effect of the common factors only. Otherwise continued iterating towards time preservation.

This commit is contained in:
Thomas Harte
2016-08-03 07:49:00 -04:00
parent a3a3486f54
commit e15241dc3c
5 changed files with 27 additions and 6 deletions
+11 -3
View File
@@ -40,12 +40,12 @@ struct Time {
return (float)length / (float)clock_rate;
}
inline bool operator<(Time &other)
inline bool operator<(Time other)
{
return other.clock_rate * length < clock_rate * other.length;
}
inline Time operator+(Time &other)
inline Time operator+(Time other)
{
Time result;
result.clock_rate = NumberTheory::least_common_multiple(clock_rate, other.clock_rate);
@@ -53,7 +53,15 @@ struct Time {
return result;
}
inline Time operator-(Time &other)
inline Time &operator +=(Time other)
{
unsigned int combined_clock_rate = NumberTheory::least_common_multiple(clock_rate, other.clock_rate);
length = length * (combined_clock_rate / clock_rate) + other.length * (combined_clock_rate / other.clock_rate);
clock_rate = combined_clock_rate;
return *this;
}
inline Time operator-(Time other)
{
Time result;
result.clock_rate = NumberTheory::least_common_multiple(clock_rate, other.clock_rate);