avoid floating point multiplication and division to ensure reproducible results

This commit is contained in:
Mathieu Lacage committed 2010-07-05 16:38:11 +02:00
1 parent 8fcd5695d9
commit 618ba84f4f
21 files changed
+10 -6

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10 -6
View File
@@ -120,14 +120,17 @@ TimeUnit<1>::TimeUnit (const std::string& s)
iss.str (s);
double v;
iss >> v;
m_data = HighPrecision (v * TimeStepPrecision::g_tsPrecFactor);
m_data = HighPrecision (v);
m_data.Mul (HighPrecision (TimeStepPrecision::g_tsPrecFactor, false));
}
double
TimeUnit<1>::GetSeconds (void) const
{
double timeValue = GetHighPrecision ().GetDouble ();
return timeValue / TimeStepPrecision::g_tsPrecFactor;
HighPrecision tmp = GetHighPrecision ();
HighPrecision factor = HighPrecision (TimeStepPrecision::g_tsPrecFactor, false);
tmp.Div (factor);
return tmp.GetDouble ();
}
int64_t
@@ -285,9 +288,10 @@ std::istream& operator>> (std::istream& is, Time & time)
Time Seconds (double seconds)
{
double d_sec = seconds * TimeStepPrecision::g_tsPrecFactor;
return Time (HighPrecision (d_sec));
// return Time (HighPrecision ((int64_t)d_sec, false));
HighPrecision tmp = HighPrecision (seconds);
HighPrecision factor = HighPrecision (TimeStepPrecision::g_tsPrecFactor, false);
tmp.Mul (factor);
return Time (tmp);
}
uint64_t