Fix unit conversion of negative Times
Thanks to Vedran for finding this.
Example:
Time tneg = Seconds (-1);
NS_LOG_UNCOND ( tneg << ", in s: " << tneg.ToInteger (Time::S));
produces
-1000000000.0ns, in s: 18446744072
Correct result is
-1000000000.0ns, in s: -1
--- a/src/core/model/nstime.h Wed Jul 24 17:15:33 2013 -0700
+++ b/src/core/model/nstime.h Thu Jul 25 12:17:08 2013 -0700
@@ -414,7 +414,7 @@
{
bool toMul;
bool fromMul;
- uint64_t factor;
+ int64_t factor;
int64x64_t timeTo;
int64x64_t timeFrom;
};
--- a/src/core/model/time.cc Wed Jul 24 17:15:33 2013 -0700
+++ b/src/core/model/time.cc Thu Jul 25 12:17:08 2013 -0700
@@ -108,7 +108,7 @@
for (int i = 0; i < Time::LAST; i++)
{
int shift = power[i] - power[(int)unit];
- uint64_t factor = (uint64_t) std::pow (10, std::fabs (shift));
+ int64_t factor = (int64_t) std::pow (10, std::fabs (shift));
struct Information *info = &resolution->info[i];
info->factor = factor;
if (shift == 0)