aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/round.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/jtutil/round.cc')
-rw-r--r--src/jtutil/round.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/jtutil/round.cc b/src/jtutil/round.cc
index 7ac60f1..123eb48 100644
--- a/src/jtutil/round.cc
+++ b/src/jtutil/round.cc
@@ -2,9 +2,9 @@
// $Id$
//
// *** Implementation Notes ***
-// round::to_integer
-// round::floor
-// round::ceiling
+// jtutil::round::to_integer
+// jtutil::round::floor
+// jtutil::round::ceiling
//
// ***** template instantiations *****
//
@@ -27,6 +27,8 @@
//******************************************************************************
// round to nearest integer, up for exact tie
+namespace jtutil
+ {
template <typename fp>
int round<fp>::to_integer(fp x)
{
@@ -34,9 +36,12 @@ return (x >= 0.0)
? int(x + 0.5) // eg 3.6 --> int(4.1) = 4
: - int( (-x) + 0.5 ); // eg -3.6 --> - int(4.1) = -4
}
+ } // namespace jtutil::
//******************************************************************************
+namespace jtutil
+ {
template <typename fp>
int round<fp>::floor(fp x)
{
@@ -44,9 +49,12 @@ return (x >= 0.0)
? int(x)
: - ceiling(-x);
}
+ } // namespace jtutil::
//******************************************************************************
+namespace jtutil
+ {
template <typename fp>
int round<fp>::ceiling(fp x)
{
@@ -54,6 +62,7 @@ return (x >= 0.0)
? int(x) + (x != fp(int(x)))
: - floor(-x);
}
+ } // namespace jtutil::
//******************************************************************************
//******************************************************************************
@@ -64,7 +73,7 @@ return (x >= 0.0)
//
// instantiation for <float>
-template class round<float>;
+template class jtutil::round<float>;
// instantiations for <double>
-template class round<double>;
+template class jtutil::round<double>;