add Abs/Max/Min non-member functions

This commit is contained in:
Mathieu Lacage
2006-11-03 09:17:13 +01:00
parent 4c969e8fbe
commit 3cd499c1a7
2 changed files with 38 additions and 1 deletions

View File

@@ -159,4 +159,38 @@ HighPrecision::Zero (void)
#endif /* HIGH_PRECISION_I128 */
HighPrecision Abs (HighPrecision const &value)
{
if (value.Compare (HighPrecision::Zero ()) <= 0)
{
return HighPrecision::Zero ().Sub (value);
}
else
{
return value;
}
}
HighPrecision Max (HighPrecision const &a, HighPrecision const &b)
{
if (a.Compare (b) >= 0)
{
return a;
}
else
{
return b;
}
}
HighPrecision Min (HighPrecision const &a, HighPrecision const &b)
{
if (a.Compare (b) <= 0)
{
return a;
}
else
{
return b;
}
}
}; /* namespace ns3 */

View File

@@ -54,7 +54,6 @@ private:
int64_t m_low;
};
#else /* HIGH_PRECISION_I128 */
/**
@@ -88,6 +87,10 @@ private:
#endif /* HIGH_PRECISION_I128 */
HighPrecision Abs (HighPrecision const &value);
HighPrecision Max (HighPrecision const &a, HighPrecision const &b);
HighPrecision Min (HighPrecision const &a, HighPrecision const &b);
}; /* namespace ns3 */
#endif /* HIGH_PRECISION_H */