comparison src/vamp-sdk/RealTime.cpp @ 476:15348e89c1d7

Fix fairly obscure mis-canonicalisation in RealTime (leading to non-canonical but still correct values)
author Chris Cannam
date Fri, 18 Nov 2016 12:53:21 +0000
parents e2716b9352ca
children ea8e56f0796a
comparison
equal deleted inserted replaced
475:e2716b9352ca 476:15348e89c1d7
80 if (sec == 0) { 80 if (sec == 0) {
81 while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; } 81 while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; }
82 while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; } 82 while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; }
83 } else if (sec < 0) { 83 } else if (sec < 0) {
84 while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; } 84 while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; }
85 while (nsec > 0) { nsec -= ONE_BILLION; ++sec; } 85 while (nsec > 0 && sec < 0) { nsec -= ONE_BILLION; ++sec; }
86 } else { 86 } else {
87 while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; } 87 while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; }
88 while (nsec < 0) { nsec += ONE_BILLION; --sec; } 88 while (nsec < 0 && sec > 0) { nsec += ONE_BILLION; --sec; }
89 } 89 }
90 } 90 }
91 91
92 RealTime 92 RealTime
93 RealTime::fromSeconds(double sec) 93 RealTime::fromSeconds(double sec)