]> git.donarmstrong.com Git - lilypond.git/blob - src/misc.cc
release: 0.0.27
[lilypond.git] / src / misc.cc
1 #include "misc.hh"
2 #include "glob.hh"
3 #include "moment.hh"
4
5 #include <math.h>
6
7 Moment
8 wholes(int dur, int dots)
9 {
10     if (!dur)
11         return 0.0;
12
13     // stupid Intel: doesn't crash if !dur
14     Moment f = Rational(1)/Moment(dur);
15     Moment delta = f;
16
17     while (dots--) {
18         delta /= 2.0;
19         f += delta;
20     }
21     return f;    
22 }
23 int
24 intlog2(int d) {
25     int i=0;
26     while (!(d&1)) {
27         d/= 2;
28         i++;
29     }
30     assert(!(d/2));
31     return i;
32 }
33
34 double
35 log_2(double x) {
36     return log(x)  /log(2.0);
37 }
38