summaryrefslogtreecommitdiff
path: root/src/third_party/s2/util/math/mathutil.cc
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/third_party/s2/util/math/mathutil.cc
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/third_party/s2/util/math/mathutil.cc')
-rwxr-xr-xsrc/third_party/s2/util/math/mathutil.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/third_party/s2/util/math/mathutil.cc b/src/third_party/s2/util/math/mathutil.cc
index 35ab462027c..7ca3b890f8a 100755
--- a/src/third_party/s2/util/math/mathutil.cc
+++ b/src/third_party/s2/util/math/mathutil.cc
@@ -16,6 +16,19 @@ using std::vector;
#include "base/integral_types.h"
#include "base/logging.h"
+ template <class IntOut, class FloatIn>
+ IntOut MathUtil::Round(FloatIn x) {
+ COMPILE_ASSERT(!MathLimits<FloatIn>::kIsInteger, FloatIn_is_integer);
+ COMPILE_ASSERT(MathLimits<IntOut>::kIsInteger, IntOut_is_not_integer);
+
+ // We don't use sgn(x) below because there is no need to distinguish the
+ // (x == 0) case. Also note that there are specialized faster versions
+ // of this function for Intel processors at the bottom of this file.
+ return static_cast<IntOut>(x < 0 ? (x - 0.5) : (x + 0.5));
+ }
+
+template int MathUtil::Round<int,double>(double x);
+
MathUtil::QuadraticRootType MathUtil::RealRootsForQuadratic(long double a,
long double b,
long double c,