diff options
author | Josh Blum | 2013-06-22 19:24:34 -0700 |
---|---|---|
committer | Josh Blum | 2013-06-22 19:24:34 -0700 |
commit | 1cebdcfb645ca6abefaa5e2d8feac8140e95e5ad (patch) | |
tree | a4c67de25d394cec0e839c73a9454c3673f82d9c /lib/time_tag.cpp | |
parent | 407a198a07dc1a333bda8b5c2e731ce0ee793ebf (diff) | |
download | sandhi-1cebdcfb645ca6abefaa5e2d8feac8140e95e5ad.tar.gz sandhi-1cebdcfb645ca6abefaa5e2d8feac8140e95e5ad.tar.bz2 sandhi-1cebdcfb645ca6abefaa5e2d8feac8140e95e5ad.zip |
gras: various fixes for new time tag class
Diffstat (limited to 'lib/time_tag.cpp')
-rw-r--r-- | lib/time_tag.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/time_tag.cpp b/lib/time_tag.cpp index d438fc3..b2beadf 100644 --- a/lib/time_tag.cpp +++ b/lib/time_tag.cpp @@ -45,17 +45,19 @@ TimeTag TimeTag::from_pmc(const PMCC &p) return normalize(t); } -time_ticks_t TimeTag::to_ticks(void) +time_ticks_t TimeTag::to_ticks(void) const { return _fsecs*time_tps() + _ticks; } -time_ticks_t TimeTag::to_ticks(const double rate) +time_ticks_t TimeTag::to_ticks(const double rate) const { - return _fsecs*time_tps() + boost::math::llround((_ticks*rate)/time_tps()); + const time_ticks_t full = time_ticks_t(_fsecs*rate); + const double error = _fsecs - (full/rate); + return full + boost::math::llround(_ticks*rate/time_tps() + error*rate); } -PMCC TimeTag::to_pmc(void) +PMCC TimeTag::to_pmc(void) const { PMCTuple<2> tuple; tuple[0] = PMC_M<boost::uint64_t>(_fsecs); |