diff options
Diffstat (limited to 'src/jtutil/round.cc')
-rw-r--r-- | src/jtutil/round.cc | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/jtutil/round.cc b/src/jtutil/round.cc index 3c2d7e6..6559944 100644 --- a/src/jtutil/round.cc +++ b/src/jtutil/round.cc @@ -14,12 +14,6 @@ #include "stdc.h" #include "util.hh" -// everything in this file is inside these namespaces -namespace AHFinderDirect - { -namespace jtutil - { - //****************************************************************************** //****************************************************************************** //****************************************************************************** @@ -35,6 +29,8 @@ namespace jtutil //****************************************************************************** // round to nearest integer, up for exact tie +namespace jtutil + { template <typename fp_t> int round<fp_t>::to_integer(fp_t x) { @@ -42,9 +38,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_t> int round<fp_t>::floor(fp_t x) { @@ -52,9 +51,12 @@ return (x >= 0.0) ? int(x) : - ceiling(-x); } + } // namespace jtutil:: //****************************************************************************** +namespace jtutil + { template <typename fp_t> int round<fp_t>::ceiling(fp_t x) { @@ -62,6 +64,7 @@ return (x >= 0.0) ? int(x) + (x != fp_t(int(x))) : - floor(-x); } + } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -71,12 +74,5 @@ return (x >= 0.0) // ***** template instantiations ***** // -template class round<float>; -template class round<double>; - -//****************************************************************************** -//****************************************************************************** -//****************************************************************************** - - } // namespace jtutil - } // namespace AHFinderDirect +template class jtutil::round<float>; +template class jtutil::round<double>; |