MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / osvrTimeValueNormalize

Function osvrTimeValueNormalize

src/osvr/Util/TimeValueC.cpp:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42#define OSVR_USEC_PER_SEC 1000000;
43
44void osvrTimeValueNormalize(OSVR_INOUT_PTR OSVR_TimeValue *tv) {
45 if (!tv) {
46 return;
47 }
48 const OSVR_TimeValue_Microseconds rem =
49 tv->microseconds / OSVR_USEC_PER_SEC;
50 tv->seconds += rem;
51 tv->microseconds -= rem * OSVR_USEC_PER_SEC;
52 /* By here, abs(microseconds) < OSVR_USEC_PER_SEC:
53 now let's get signs the same. */
54 if (tv->seconds > 0 && tv->microseconds < 0) {
55 tv->seconds--;
56 tv->microseconds += OSVR_USEC_PER_SEC;
57 } else if (tv->seconds < 0 && tv->microseconds > 0) {
58 tv->seconds++;
59 tv->microseconds -= OSVR_USEC_PER_SEC;
60 }
61}
62
63void osvrTimeValueSum(OSVR_INOUT_PTR OSVR_TimeValue *tvA,
64 OSVR_IN_PTR const OSVR_TimeValue *tvB) {

Callers 3

osvrTimeValueSumFunction · 0.85
osvrTimeValueDifferenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected