mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-03 15:29:45 +00:00
Ensure float literals are floats.
This commit is contained in:
parent
8dcb48254a
commit
a7855e8c98
@ -69,16 +69,16 @@ void TimedEventLoop::set_next_event_time_interval(Time interval) {
|
|||||||
|
|
||||||
void TimedEventLoop::set_next_event_time_interval(float interval) {
|
void TimedEventLoop::set_next_event_time_interval(float interval) {
|
||||||
// Calculate [interval]*[input clock rate] + [subcycles until this event]
|
// 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
|
// This event will fire in the integral number of cycles from now, putting us at the remainder
|
||||||
// number of subcycles
|
// number of subcycles.
|
||||||
const Cycles::IntType addition = Cycles::IntType(float_interval);
|
const Cycles::IntType addition = Cycles::IntType(float_interval);
|
||||||
cycles_until_event_ += addition;
|
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(cycles_until_event_ >= 0);
|
||||||
assert(subcycles_until_event_ >= 0.0);
|
assert(subcycles_until_event_ >= 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Time TimedEventLoop::get_time_into_next_event() {
|
Time TimedEventLoop::get_time_into_next_event() {
|
||||||
|
@ -103,7 +103,7 @@ namespace Storage {
|
|||||||
private:
|
private:
|
||||||
Cycles::IntType input_clock_rate_ = 0;
|
Cycles::IntType input_clock_rate_ = 0;
|
||||||
Cycles::IntType cycles_until_event_ = 0;
|
Cycles::IntType cycles_until_event_ = 0;
|
||||||
float subcycles_until_event_ = 0.0;
|
float subcycles_until_event_ = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user