diff --git a/src/simulator/nstime.h b/src/simulator/nstime.h index a0f1e0394..c0b2d87d7 100644 --- a/src/simulator/nstime.h +++ b/src/simulator/nstime.h @@ -110,7 +110,7 @@ public: * \return the ns3::HighPrecision object which holds the value * stored in this Time type. */ - HighPrecision GetHighPrecision (void) const; + HighPrecision const &GetHighPrecision (void) const; HighPrecision *PeekHighPrecision (void); private: @@ -138,7 +138,7 @@ TimeUnit::TimeUnit (HighPrecision data) {} template -HighPrecision +HighPrecision const & TimeUnit::GetHighPrecision (void) const { return m_data; diff --git a/src/simulator/time.cc b/src/simulator/time.cc index 212dd0cab..f5605f03c 100644 --- a/src/simulator/time.cc +++ b/src/simulator/time.cc @@ -36,23 +36,21 @@ Time::Time (HighPrecision const& value) double Time::GetSeconds (void) const { - HighPrecision seconds = GetHighPrecision (); - seconds.Div (HighPrecision (1000000000, false)); - return seconds.GetDouble (); + double ns = GetHighPrecision ().GetDouble (); + return ns/1000000000.0; } int32_t Time::GetMilliSeconds (void) const { - HighPrecision ms = GetHighPrecision (); - ms.Div (HighPrecision (1000000, false)); - return (int32_t) ms.GetInteger (); + int64_t ns = GetHighPrecision ().GetInteger (); + ns /= 1000000; + return ns; } int64_t Time::GetMicroSeconds (void) const { - HighPrecision us = GetHighPrecision (); - us.Div (HighPrecision (1000, false)); - return us.GetInteger (); + int64_t ns = GetHighPrecision ().GetInteger (); + return ns/1000; } int64_t Time::GetNanoSeconds (void) const