]> git.donarmstrong.com Git - lilypond.git/blob - lily/misc.cc
2003 -> 2004
[lilypond.git] / lily / misc.cc
1 /*
2   misc.cc -- implement various stuff
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7     Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include <math.h>
11 #include "misc.hh"
12
13 /*
14   Return the 2-log, rounded down 
15  */
16 int
17 intlog2 (int d)
18 {
19   assert (d);
20   int i=0;
21   while ((d != 1)) 
22     {
23       d /= 2;
24       i++;
25     }
26   
27   assert (! (d/2));
28   return i;
29 }
30
31 double
32 log_2 (double x)
33 {
34   return log (x)  /log (2.0);
35 }
36