1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Ensure float literals are floats.

This commit is contained in:
Thomas Harte 2020-07-17 23:18:41 -04:00
parent 8dcb48254a
commit a7855e8c98
2 changed files with 6 additions and 6 deletions

View File

@ -69,16 +69,16 @@ void TimedEventLoop::set_next_event_time_interval(Time interval) {
void TimedEventLoop::set_next_event_time_interval(float interval) {
// Calculate [interval]*[input clock rate] + [subcycles until this event]
float float_interval = interval * float(input_clock_rate_) + subcycles_until_event_;
const float float_interval = interval * float(input_clock_rate_) + subcycles_until_event_;
// So this event will fire in the integral number of cycles from now, putting us at the remainder
// number of subcycles
// This event will fire in the integral number of cycles from now, putting us at the remainder
// number of subcycles.
const Cycles::IntType addition = Cycles::IntType(float_interval);
cycles_until_event_ += addition;
subcycles_until_event_ = fmodf(float_interval, 1.0);
subcycles_until_event_ = fmodf(float_interval, 1.0f);
assert(cycles_until_event_ >= 0);
assert(subcycles_until_event_ >= 0.0);
assert(subcycles_until_event_ >= 0.0f);
}
Time TimedEventLoop::get_time_into_next_event() {

View File

@ -103,7 +103,7 @@ namespace Storage {
private:
Cycles::IntType input_clock_rate_ = 0;
Cycles::IntType cycles_until_event_ = 0;
float subcycles_until_event_ = 0.0;
float subcycles_until_event_ = 0.0f;
};
}