]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4847: Let intlog2 adapt to argument precision
authorDavid Kastrup <dak@gnu.org>
Wed, 4 May 2016 20:50:36 +0000 (22:50 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 10 May 2016 18:55:08 +0000 (20:55 +0200)
Makes a few warnings disappear without compromising precision.

lily/include/misc.hh
lily/misc.cc

index 7226aceef8d7a5d31d3530c8a7c88bd78148a578..174b2f4c01663be76fed63778e558d03cf708d6f 100644 (file)
@@ -27,7 +27,26 @@ using namespace std;
 #include "interval.hh"
 
 double log_2 (double x);
-int intlog2 (int d);
+
+/*
+  Return the 2-log, rounded down
+*/
+template <class T>
+int
+intlog2 (T d)
+{
+  if (d <= 0)
+    error ("intlog2 with negative argument: " + ::to_string (d));
+  int i = 0;
+  while ((d != 1))
+    {
+      d /= 2;
+      i++;
+    }
+
+  assert (! (d / 2));
+  return i;
+}
 
 inline int
 sign (int i)
index b930fd521a50e4eb2c93d69736591cac7a7b402e..6cafa2b50b3669fac258e5d2b1d3e51cdb737db1 100644 (file)
 #include "offset.hh"
 #include "warn.hh"
 
-/*
-  Return the 2-log, rounded down
-*/
-int
-intlog2 (int d)
-{
-  if (d <= 0)
-    error ("intlog2 with negative argument: " + ::to_string (d));
-  int i = 0;
-  while ((d != 1))
-    {
-      d /= 2;
-      i++;
-    }
-
-  assert (! (d / 2));
-  return i;
-}
-
 double
 log_2 (double x)
 {