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
This commit is contained in:
@@ -414,7 +414,7 @@ private:
|
||||
{
|
||||
bool toMul;
|
||||
bool fromMul;
|
||||
uint64_t factor;
|
||||
int64_t factor;
|
||||
int64x64_t timeTo;
|
||||
int64x64_t timeFrom;
|
||||
};
|
||||
|
||||
@@ -108,7 +108,7 @@ Time::SetResolution (enum Unit unit, struct Resolution *resolution)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user