From be1be806d2ce576bc23c7ac62227d24fbd6800c5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 30 Aug 2011 17:24:40 -0700 Subject: uhd: also normalise the time spec when adding/subtracting (added unit test) --- host/lib/types/time_spec.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'host/lib') diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index 0224fb6c2..e019f1ccd 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -128,14 +128,18 @@ double time_spec_t::get_frac_secs(void) const{ * Time spec math overloads **********************************************************************/ time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){ - this->_full_secs += rhs.get_full_secs(); - this->_frac_secs += rhs.get_frac_secs(); + time_spec_init( + this->_full_secs + rhs.get_full_secs(), + this->_frac_secs + rhs.get_frac_secs() + ); return *this; } time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){ - this->_full_secs -= rhs.get_full_secs(); - this->_frac_secs -= rhs.get_frac_secs(); + time_spec_init( + this->_full_secs - rhs.get_full_secs(), + this->_frac_secs - rhs.get_frac_secs() + ); return *this; } -- cgit v1.2.3