From e8fc528e34f5daf0987711906b6d91630e64ce85 Mon Sep 17 00:00:00 2001 From: Greg Steinbrecher Date: Wed, 30 Sep 2020 16:05:32 -0700 Subject: [PATCH] network: (fixes #264, merges !432) Rounding behavior of DataRate methods Improve rounding behavior of CalculateBytesTxTime and CalculateBitsTxTime --- src/network/utils/data-rate.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/network/utils/data-rate.cc b/src/network/utils/data-rate.cc index 5b65a4921..769171d9b 100644 --- a/src/network/utils/data-rate.cc +++ b/src/network/utils/data-rate.cc @@ -24,7 +24,7 @@ #include "ns3/log.h" namespace ns3 { - + NS_LOG_COMPONENT_DEFINE ("DataRate"); ATTRIBUTE_HELPER_CPP (DataRate); @@ -229,15 +229,13 @@ bool DataRate::operator != (const DataRate& rhs) const Time DataRate::CalculateBytesTxTime (uint32_t bytes) const { NS_LOG_FUNCTION (this << bytes); - // \todo avoid to use double (if possible). - return Seconds (static_cast(bytes)*8/m_bps); + return Seconds (bytes * 8) / m_bps; } Time DataRate::CalculateBitsTxTime (uint32_t bits) const { NS_LOG_FUNCTION (this << bits); - // \todo avoid to use double (if possible). - return Seconds (static_cast(bits)/m_bps); + return Seconds (bits) / m_bps; } uint64_t DataRate::GetBitRate () const