1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 11:44:53 +08:00

Divide by 1e9 to get seconds from nanoseconds, instead of 1e6.

This commit is contained in:
Mike Purvis 2013-10-31 21:48:44 -04:00
parent cfac5bbcc9
commit 2e5e8f940b

View File

@ -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;
}
}