Skip to content

Commit 552090b

Browse files
committed
Avoid off by one error, rounding GetTicks calc
GetTicks cast the result from double to uint64_t, occasionally causing errors of one tick. E.g. 6143.999999904 will be returned as 6143 while the correct value is 6144. Proper rounding fixes the problem.
1 parent 2c9a268 commit 552090b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/streaming/Timespec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ uint64_t Timespec::GetTicks() const
8686
{
8787
if (seconds < 0)
8888
return 0;
89-
return seconds * ticksPerSecond + fracSeconds * ticksPerSecond;
89+
return round(seconds * ticksPerSecond + fracSeconds * ticksPerSecond);
9090
}
9191

9292
double Timespec::GetRealSeconds() const

0 commit comments

Comments
 (0)