mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
Divide by 1e9 to get seconds from nanoseconds, instead of 1e6.
This commit is contained in:
parent
cfac5bbcc9
commit
2e5e8f940b
@ -60,8 +60,8 @@ MillisecondTimer::MillisecondTimer (const uint32_t millis)
|
||||
{
|
||||
int64_t tv_nsec = expiry.tv_nsec + (millis * 1e6);
|
||||
if (tv_nsec > 1e9) {
|
||||
int64_t sec_diff = tv_nsec / static_cast<int> (1e6);
|
||||
expiry.tv_nsec = tv_nsec - static_cast<int> (1e6 * sec_diff);
|
||||
int64_t sec_diff = tv_nsec / static_cast<int> (1e9);
|
||||
expiry.tv_nsec = tv_nsec - static_cast<int> (1e9 * sec_diff);
|
||||
expiry.tv_sec += sec_diff;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user