summaryrefslogtreecommitdiff
path: root/lily/misc.cc
blob: adcf536ad26dc9130d215ec1f4d42f74d2e384f8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
  misc.cc -- implement various stuff

  source file of the GNU LilyPond music typesetter

  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
    Jan Nieuwenhuizen <janneke@gnu.org>
*/

#include <math.h>
#include "misc.hh"

/*
  Return the 2-log, rounded down 
 */
int
intlog2 (int d)
{
  assert (d);
  int i=0;
  while ((d != 1)) 
    {
      d /= 2;
      i++;
    }
  
  assert (! (d/2));
  return i;
}

double
log_2 (double x)
{
  return log (x)  /log (2.0);
}